I came up with something handy for EditPlus users out there who might need to execute something on a remote machine (like say the linux box that has the samba share your files are being accessed throught).
My situation is that we use templating on all of our files that needs to be regenerated each time there’s a change made. Previously, this meant having two windows open – one for EditPlus and another that’s a ssh session at the directory you’re working with. Well, in one of those “surely there’s a better way” moments this morning, I did some digging and came up with this process:
– Using the “user tools” in EditPlus, create a connection to a remote machine
– via plink (Win) to ssh to the machine
– and execute the command over that interface
Well, it look a little PHP trickery to get it working exactly right, but here’s how:
- Download plink
- In EditPlus, go to Tools -> Configure User Tools
- Hit “Add” and choose “Program”
- Change the program name (in the “Menu Text”) to your liking
- Add the command to execute in the Command box.
In my case, I wanted to connect to the remote machine over ssh and run the command to retemplate the file I was working on. Here’s what I put:
- Add an argument
I put the value of ‘$(FilePathNoDrv)’ in there (yes, with the quotes) to append the path to the file without the drive letter
- Click “Capture Output” and “Save open files”
- Hit “Ok” to save the changes
Then you can check your Tools menu to see what the keystroke for it is and voila – you’re all set. It’s nice that it gives the option to save the file when you execute the tool. Anything that makes for less keystrokes for me!
The PHP script on the other side had to do a little something to handle EditPlus’ input correctly – here’s the example:
#!/usr/local/bin/php $in=file_get_contents("php://input"); exec('/usr/local/bin/template.sh /www/web/'.str_replace('\\','/',$_SERVER['argv']),$out); //print_r($out);
I left that $out in there just in case you might need to have some debugging output. Because of the way that the script passes in the values (it is a Windows software after all), we have to switch around the slashes to work with the linux file system. So, if in EditPlus my path is like H:\www\docroot\myfile.tpf the script will map it over to /www/docroot/myfile.tpf and run the template.sh on it to retemplate it.
There we go – hope it’s helpful!