A few times while traveling around Australia, either I’ve noticed a slight glitch on a site (Stopdesign, or a client site), or someone else points out a bug or problem with some file on a site I have control over. I left my laptop and cables, etc. in Sydney to shed the weight, so I haven’t had access to the tools I normally have at my disposal. Any of these changes are usually quick edits or corrections of previous oversights, assuming I have any type of net connection and my normal toolset with me. However, I’ve been missing some sort of text editor that can work on files remotely via S/FTP.
Many of the Win PCs in internet cafes are configured with quite a few restrictions, such as the inability to run anything from the command line. For me, it would be highly convenient if I could just SSH into any server I have access to, open the offending file with pico or vi, make any necessary changes, save, and be done with it. But since I’m unable to run cmd.exe from many of these machines, I hadn’t discovered an easy way to edit files remotely.
That is, until I remembered how easily I could edit any text file on the server by logging into the copy of Movable Type installed on that server. MT has come in quite handy over the past week as a make-shift CMS that can modify more than just blog entries and associated templates. It can actually be used to edit any text-based file within its reach.
The how to: Simply create a new Index Template, make sure absolutely nothing is in the Template Body field (not even a single space character), then link that template to any existing file on the server by using a path relative to the Local Site Path set on the Weblog Config > Core Setup page (this is in MT2.6 — it might be named something different in MT3.x).
For instance: If your Local Site Path is set to the home directory of your web server, and you have a file called
header.php within a
functions directory at the next level down, set the Link this template to a file path to
functions/header.php with no initial slash, ensure nothing is in the Template Body field, save the template, and the contents of that file will be loaded into the previously empty Template Body field, giving you full access to edit the file any way you want.
Put into practice, one of my PHP functions was misbehaving last week because of improper syntax. I simply pointed a new index template at that file, made the needed changes, then saved the template which overwrote the file, and the problem was fixed. Same thing was done to fix a few bugs on Maggie’s Mighty Goods site. You can either choose to keep the template file in case you might want to change it later, or you can toss it to keep your template list short and clean. I prefix any of the template names I create for this purpose with REMOTE:, in case I forget to delete it, and come back later wondering why that template exists. I know anything with REMOTE: in the name is disposable and not relevant to the core functionality or content of the site.
It’s possible there’s an even easier means of editing remotely. But MT is working quite well for my purposes, and it’s dead simple to use in this manner.