Reputation: 603
I'm attempting to launch putty via the command line in such a way that it runs a command on the server (I want to create a windows shortcut, to tail a log file)
So far I have a batch file containing this
"C:\Program Files (x86)\PuTTY\putty.exe" -ssh -t -pw -m tail_catalina_out -load "myprofile"
And within my server I have a file at the root directory named tail_catalina_out with the following contents.
tail -f /opt/tomcat/logs/catalina.out
Putty launches and my session starts successfully, but no command appears to be carried out despite this? Am I misunderstanding how this works?
Upvotes: 0
Views: 1459
Reputation: 38781
You don't need -ssh
with -load profile
(and if you use a nonstandard port like my test it doesn't work at all); in fact you don't need it with [user@]host
because it's the default
-pw -m tail_catalina_out
uses -m
as your password (which I hope is incorrect, so you should be reprompted unless publickey auth is set-up) and ignores tail_catalina_out
the file for -m
must be local i.e. on the PuTTY machine not on the server (although the commands in it will be sent to, and must be valid on, the server)
Thus: "\path\to\putty" -t -m localcmdfile -load profile
You could also use plink
which runs in the console and takes either -m localfile
or the actual remote command on the command line after the last option (like the OpenSSH client ssh
):
"\path\to\plink" -t -load profile tail -f remotefile
As usual, you can omit the quotes around the path if it contains no space. Personally I use \progra~2
instead of bothering with "\program files (x86)"
but that's just me, and it may depend on a clean install (instead of upgrade).
Upvotes: 1