Very Basic Midnight Commander Script for larger files and SSH remote file copy


Recommended Posts

Unless there is someone with a better solution (which I'm sure there is) I have this small script I've made for use with midnight commander. When you use MC to open a remote SSH directory to a remote server, and try to do large file copies, the space that gets used as temporary space for this copy resides on the thumb drive. So if you're trying to copy a file larger than your available space on your thumb drive to a remote server via an SSH connection, the command fails. Also, I feel like the less reading and writing to the thumb drive the better as it would prolong it's life I suppose. I'm not sure if unRAID MC does this for local to local copies, but for anyone who uses it to transfer files to a remote SSH directory I've made this simple script. It does require the unRAID Nerdtools plugin (with screen turned on of course), and a directory on the cache drive named /mnt/cache/mctmp which should be chmodded to 777. When this command is invoked it will either create a new screen session with the temp file copying directory at /mnt/cache/mctmp, or if a screen session is already running it will drop you back into it. The file itself should be named startmc.sh, chmodded +x, and put on your flash drive somewhere like /boot/config/startmc.sh. You would also need to add the following line to your go script

 

cp /boot/config/startmc.sh /usr/bin

 

Here is the code for the actual file itself. You would first type

 

nano /boot/config/startmc.sh

 

and insert the below text inside of it

 

#!/bin/bash

if ! screen -ls | grep -q "mc"; then
        /usr/bin/screen -mS mc /usr/bin/env TMPDIR=/mnt/cache/appdata/mctmp mc
else
        /usr/bin/screen -r mc
fi

 

I'm aware there are Nautilus GUIs and any number of other solutions, I just have always been used to, and liked using midnite commander as I can use it from any device with no issues at all. Any help or suggestions would be greatly appreciated.

 

 

Link to comment

We are in the process of changing dedi providers atm. but I can replicate it in a few days. This was very old, and I had just given it to another geek user and thought I'd post it here. I believe mc by default uses FISH for this process, the transfer to a remote server, and from what I recall it's either /home/user/.config/mc or /etc/mc. It took me a while to get the correct flag there to make the temp dir different for just FISH, but it was simply for those remote transfers that used FISH that I noticed the issue. So like I said, I rarely have to even use this for anything but these remote copies.

When we get our new dedi up and running I'll confirm this for you. We also only use cert based, as well as login/pw auth for connection to our remote servers. So tbh I'm not sure if that would be a factor and it uses a different protocol for remote file transfer, but I thought I'd mention it.

Link to comment

... from what I recall it's either /home/user/.config/mc or /etc/mc...

Neither of these locations is in /boot

 

The flash drive is at /boot

 

The drives and user shares are in /mnt

 

All other locations, such as /home or /etc or any of the other linux locations you may be familiar with are in RAM.

 

The unRAID OS is unpacked fresh from bzimage,bzroot from the flash drive into RAM at each bootup, and only /boot and /mnt are actual storage. That is why, for example, syslog resets each time you bootup. syslog is /var/log/syslog, which is in RAM.

 

This is why I asked where in /boot, because you seemed to be under the impression the flash drive was being written to and filling up. I don't think that is correct, or at least it is incorrect unless it is actually writing to somewhere in /boot.

 

Not sure what you were experiencing with mc. I have copied files with mc larger than my flash drive or my RAM, both of which are only 16GB, though for remote I have mostly used rsync at the command line.

 

Link to comment

OK that makes more sense. Well then what I believe is happening is that FISH stores this file temporarily in either of the aforementioned directories, which are actually in RAM. So if the file you're trying to copy is larger than your free space available in RAM (my flash drive is 8GB and I have 8GB of RAM in this particular server so this is probably why I confused the two) you get an error in MC.  This script places the file temporarily on the cache drive instead of in memory or the flash drive allowing for copying of larger files via MC to a remote server. I'm quite sure this use case is for a very small number of users. I just thought since I had given it to another geek again I'd post it on here just in case anyone else ran into the same thing.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.