The opportunity – your hosting account offers you shell access! 😀
The problem – they don’t have Midnight Commander installed! 😥
The background (skip to the solution!)
Ok for some of you, none of this is a problem. You don’t have shell access on your shared hosting account – most don’t. For others, you have shell access and Midnight Commander is installed already – great! For other, you live and breathe for the Linux command line and your intimate knowledge of command syntax and Linux “innards” means you can create a symphony with your keyboard.
I, however, am not a Linux “heavy” and my shared hosting account with O2switch (which I think is a REAL deal, given what you get and the price you pay) provides shell access but no Midnight Commander. I have done some Linux server management in a mixed platform environment and appreciate what Linux brings to the table but I’m a Windows guy and a visual person. Consequently, when I see that I have shell access, I’m glad to have the ability to do certain things that simple ftp access doesn’t give me. On the other hand, given ONLY a command line, my productivity plummets. Don’t get me wrong, I appreciate what can be done with a command line. I once worked on a mini computer where the only access was the command line for commands, navigating and editing. I loved it – but I was young and that was my job. I could afford to learn on the job and really get good and fast. Now I’ve got too many fish to fry to learn another environment when I’m not in it all the time. So for those of us who live MOSTLY in a non-Linux environment, a visual environment helps a LOT.
The problem (when the sys admins won’t install Midnight Commander for you) is that Midnight Commander doesn’t have a set of pre-compiled binaries sitting around for you to run. It depends heavily on system libraries and thus is typically dynamically linked for the distribution where it will run or is compiled from source into the environment where it will run. By default it installs in directories to which a shared hosting client doesn’t have access. Even the ONE statically-linked pre-compiled binary which I found on the internet did not work except when running from a directory to which I didn’t have access! 🙄
My issues were mostly in two areas:
- Navigation – the basic need for a file manager – the felt need for which things like Norton Commander came into existence!
- File Editing – I had access to vim and nano and neither of these are what I’d call “intuitive”. I’m not calling them “powerless”
I searched high and low and couldn’t find a solution. I thought I’d try and compile it from source. The compilers are NOT available to client accounts so I needed to compile elsewhere and then copy the executable binary to my hosting account and see if that would work. I couldn’t easily figure out what distribution O2switch used for their servers as none of those discovery commands worked. I finally asked them and they let me know that it was a CentOS derivative. So I installed a CentOS distro in a VM on my Windows machine. Not that I did everything right but that was one of the hardest distros to work with. Then I tried to see if I could compile and then static link on a Ubuntu distro in order to have a fully static-linked binary that, theoretically, I could drop in and run. I’d never compiled on a Linux machine so there were things that made sense from days compiling on IBM mainframes but there was a lot that I didn’t get and I was really going around in circles.
I looked for other ncurses-based file managers and/or editors. I got Ranger to work, but it was WAY different than what I was used to while it helped me navigate a little bit, it still required a knowledge of a set of commands (it has a vi-based interaction) that I simply didn’t have and that were NOT intuitive from my background. I tried to get the Diakonos editor to work (written in Ruby), but I don’t know Ruby at all and I barely got anything to run and the system-dependencies it had required that I try to make an older version run…blah, blah, blah – just a mess!
So I finally went to the mailing list of the Midnight Commander project to ask the experts. I found THE resource that I needed in Erdmut Pfeifer on that list. He gave me the foundation for…
Read the details of my conversation on the mailing list on this thread. That will give you more background on what I did and especially on the solution that Erdmut was able to give me. Here is the essence of his answer to me:
So I got his script (which you can find in the thread on the mailing list) and it worked! I had to keep tweaking some things to get it just right for my environment, but I got it to the point where I could ssh to my shell session and then type “mc” and I was in an environment that I knew and I could be productive.
Here are the steps I took to make it work in the O2switch environment. YMMV in other environments! Also this was back in September 2016 so I’ve forgotten a bit of what I did and some of my notes are not as helpful to me at the moment, but I think they’ll get the persistant going in the right direction.
- Followed Erdmut’s directions in the thread
- Used mc from CentOS 6.8 package installation (it’s version 126.96.36.199)
- Added /usr and /etc parts (oops – I don’t totally remember what this means! I think it’s creating a /usr and /etc structure in my local “mc” directory, which I named “mymc”, and copying in the files from the package installation that would normally be in the root “/usr” and root “/etc” directory structures in a typical system-wide installation)
- run strace -o ~/ztrace.txt -e trace=file ./mc and review the file not found output to see what needs to be fixed
- cp ~/mymc/etc/mc/Syntax ~/mymc/etc
- cp ~/mymc/etc/mc/mc.lib ~/mymc/etc
- cp ~/mymc/etc/mc/mc.menu ~/mymc/etc
- cp ~/mymc/usr/share/mc/skins ~/mymc/etc
- cp ~/mymc/etc/mc/filehighlight.ini ~/mymc/etc
- cp ~/mymc/etc/mc/mc.keymap ~/mymc/etc
- cp ~/mymc/usr/share/mc/mc.hint ~/mymc/etc/mc.hint. (the “.” at the end is important!) (this brings the prompt)
- cp ~/mymc/usr/share/mc/mc.hlp ~/mymc/etc/mc.hlp. (the “.” at the end is important!)
- cp ~/mymc/etc/mc/mc.ext ~/mymc/etc
- cp ~/mymc/usr/share/mc/syntax ~/mymc/etc
- redo mcedit, mcview symbolic links (this still isn’t working yet – i.e. I don’t have the “mcedit” and “mcview” commands. The editor and viewer work just fine but I can’t access them via “mcedit” and “mcview”)
- Below, I’m including a zipped up version of “~/mymc” which may work right out of the box. I have it unzipped into the root of my home directory. I would suggest doing the same.
- make symbolic link to ~ so that I can run ./mc to start (might not have to do this if you do the following)
- placed the following in ~/.bashrc so that I can simply type “mc” to start
- had to change putty’s translation settings to ISO-8859-1:1998 (Latin-1, West Europe) to make the lines correct. This is dependant on what your server’s settings are. It’ll likely be either UTF-8 or ISO-8859-1:1998 (Latin-1, West Europe)
Here’s a zipped copy of my directory “mymc” with everything you need (normally) to run Midnight Commander 188.8.131.52 as an O2switch client. You’ll have to do the path work afterward to make it more easily executable. It may work for other environments. Please let me know if it does!
Download here ==> mymc.zip