I am looking to script something in batch which will need to run remote ssh commands on Linux. I would want the output returned so I can either display it on the screen or log it.
putty.exe -ssh user@host -pw password -m command_run
-m switch of PuTTY takes a path to a script file as argument, not command.
So you have to save your command (
command_run) to a plain text file (e.g.
c:\path\command.txt) and pass that to PuTTY:
putty.exe -ssh user@host -pw password -m c:\path\command.txt
Though note that your should use Plink (a command-line connection tool from PuTTY suite). It's a console application, so you can redirect its output to a file (what you cannot do with PuTTY).
A command-line syntax is identical, an output redirection added:
plink.exe -ssh user@host -pw password -m c:\path\command.txt > output.txt
And with Plink can actually provide the command directly on its command-line:
plink.exe -ssh user@host -pw password command > output.txt