You can use the -m option to specify the file that contains the command to run on the remote connection.
Example:
C:\Progra~1\Putty\putty.exe -ssh -m C:\cmd.txt root@10.1.2.3
Content C:\cmd.txt
mysql -u USER -pPASS db < /tmp/dump.sql
From the Sleepers Documentation :
3.8.3.6 `-m ': read a remote command or script from a file
-m' option performs a similar function to the Remote Command' in the SSH panel of the PuTTY configuration window (see section 4.18.1). However, the `-m 'parameter expects to be given the name of a local file, and it will read the command from that file.
With some servers (in particular, Unix systems) you can even put several lines in this file and execute more than one command in a sequence or an entire shell script; but this is probably an abuse, and they cannot be expected to work on all servers. In particular, it is not known to work with certain βembeddedβ servers, such as Cisco routers.
This option is not available in the PSCP and PSFTP file transfer tools.
source share