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.


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@ -t netbeansprojects/RevPiTestOutput/dist/Debug/GNU-Linux/revpitestoutput


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. According to the official documentation, however, this should be treated with caution, as not all systems support multiline commands.

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@ -m command.txt

Leave a Reply

Your email address will not be published. Required fields are marked *