Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

midnight commander shortcut

Featured Replies

Hi there,

 

I use midnight commander to move data round on the server. I thought it should be possible to get a shortcut in windows that would

1) ssh or telnet into the server

2) cd to a certain directory

3) launch mc

 

I did some testing and I got it working to a certain point, but now I am stuck.

 

So here is what I have:

First, launch cygwin and start a script from cygwin home folder (this one-liner would be the windows shurtcut):

 C:\cygwin\bin\mintty.exe -ha -e script.sh

 

Second, the cygwin script:

(/usr/bin/echo open TOWER;
/usr/bin/sleep 1;
/usr/bin/echo USERNAME;
/usr/bin/sleep 2;
/usr/bin/echo PASSWORD;
/usr/bin/sleep 1;
/usr/bin/echo mc;
/usr/bin/cat) | /usr/bin/telnet

 

This WILL log into the server and start midnight commander, but the arrow keys won't work - so it's useless.

However, if I manually do a telnet login (from the very same cygwin window) and then launch mc it works just fine.

I know that this "poor man's" inline Telnet is just a dirty workaround. In fact the "/usr/bin/cat" command close to the end keeps the window interactive, otherwise it would just close and never show the midnight commander. I am not exactly sure if this is the root of the problem.

 

I also made an attempt with ssh but I got stuck there, too.

In this case the script.sh looks like this:

ssh USERNAME@TOWER "cd ../mnt/user; mc"

And it throws the error:

Cannot get terminal settings: Invalid argument (22)
TERM environment variable needs set.

I checked the TERM variable and its xterm, which is what mc likes.

 

If anyone can make it work eitherway round, that would be great.

 

Cheers!

I personally use this script. http://jerrymannel.com/blog/2008/11/11/telnet-scripting-tool-aka-tst10exe/ Seems pretty effective for moving files from one directory to another on my unRAID machine called from my Windows7 machine using a short cut or a batch script. I call it as follows.

 

C:\BatchCommands\tst10.exe /r:C:\BatchCommands\movefiles.txt

 

This is the contents of movefiles.txt

 

tower

WAIT "login:"

SEND "root\m"

WAIT "Password:"

SEND "MYPASSWORDHERE\m"

WAIT ":~#"

SEND "mv /mnt/disk3/Movies/uploads/* /mnt/disk3/Movies/All/\m"

SEND "rmdir /mnt/disk3/Movies/uploads/\m"

SEND "exit\m"

 

It simply copies all contents of one directory uploads from one location to another. Then it deletes the upload folder. I have another script I use to creates the folder when I have something to put in it. I delete it for a reason because if the folder exists then I know I have things in there I need to address before I move them.

 

Currently it does not support SSH so you have to use Telnet.

  • Author

Thanks for you feedback kizer. One solution at last, although I have some doubts: First of all the tool comes from a blog that states the original source went offline. Maybe I am paranoid, but I have troubles to trust it. Apart from that I am wondering if it has telnet build in or if it uses an external telnet application? One reason why I go for cygwin-minnty is that it I have control over font and the window goes full screen - contrary to the horrible horrible windows-cmd. MC in a cmd window ... nah.

 

If anyone still has idea why its not working the way I tried, I would be happy.

 

However, I will look now into screen now. In fact, when copying larger amounts of data (e.g. to/from USB drives) it might be better to have mc running in screen anyway, just in case ....

I made a quick test and mc seems to remain functional when a screen session gets disconnected and reconnected.

I found a small guide on how to auto-resume screen sessions here:

http://taint.org/wk/RemoteLoginAutoScreen

I am not perfectly happy with it yet, but I will do some further testing next week and report back findings.

If I can make this work nicely it would be perfectly fine. I will just leave mc running all the time, so all I need to do is create a shortcut that launches ssh and attempts a login -> one-click mc session open :)

 

Cheers!

  • Author

For testing I created a bashrc and screenrc file. For obvious reason they don't survive a reboot, so I crawled the forum a bit. The solution is to keep the files elsewhere (/boot) and copy them upon reboot to the according place (~) via the go script. I tested every single command in the terminal to verify it's doing what I want it to do. However, when I reboot nothing of it is done :(.

 

echo "if [ -f ~/.bashrc ]; then . ~/.bashrc fi" >> ~/.bash_profile
cp /boot/.bashrc ~/.bashrc
cp /boot/.screenrc ~/.screenrc

 

Cheers!

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.