Execute commands remotely

Just automate it

In one of my previous articles, I already hinted that I do not particularly like stupid work. So it often happens when working with the RevPi, that you have to execute a single command on the RevPi. It is really a waste of time to manually open a console for SSH every time and do whatever you want. It is much easier if you can send a command directly remote.

OpenSSH

The easiest way to do this is with OpenSSH. Here you can simply append a command with -t. For example, to start RevPiTestOutput from one of the previous articles, the following line is sufficient.

ssh -i revpi_connect_33093_openssh pi@192.168.178.32 -t netbeansprojects/RevPiTestOutput/dist/Debug/GNU-Linux/revpitestoutput

Putty

It’s a little more complicated with Putty. Putty does not seem to support to execute single commands as a parameter. Maybe it is due to the limitations of the Windows command line (speculation). Instead Putty supports executing whole scripts via file with -m. For this purpose I created a text file named command.txt and inserted the same command as in the OpenSSH example.

Screenshot of the Windows editor showing the contents of command.txt to run revpitestoutput

The script can be executed as follows:

putty -i revpi_connect_33093.ppk pi@192.168.178.32 -m command.txt