Page 1 of 1

Putty and commands

Posted: Tue Jun 19, 2007 2:24 pm
by alex.barylski
I'm executing putty from a Windows application.

So far I have constructed this command line, which loads putty up no problems.

Code: Select all

putty.exe -ssh hockey@192.168.1.103 -pw password
I want to execute a remote command but I assume I need to use some kind of putty script or can I just add the command to the list of switches?

According to the docs, there is an option:

Code: Select all

-m: read a remote command or script from a file
Problem is, it appears to be a file stored in the local machine, when I referenced a file on the server PUTTY complained, when I brought that into the same CWD as putty.exe (Windows version) all went fine, but no commands appear to execute and the console window closes immediately.

So I'm not sure I understand how this whole thing comes into play. When using the Windows version of PUTTY.exe and I use a remote command/script obviously the commands are intended for the remote device (this case Linux) so commands like

Code: Select all

ls, rm, cp, etc
Should be passed to the remote command line, no???

Anyone have any experience using putty through command line and executing arbitrary commands on the remote machine? What am I doing wrong?

Cheers :)

Posted: Tue Jun 19, 2007 4:16 pm
by timvw
C:\Program Files\putty\plink.exe -pw mypassword user@example.com /bin/ls -la

Posted: Tue Jun 19, 2007 4:18 pm
by alex.barylski
Edit: Just noticed you said plink. :)

Edit2: Excellent! Thanks man. I knew I should have checked those other binaries. Worked like a charm and now I get all these commands output to my editor Windows...so awesome...BAM!

I tried that :?

WTF...I'll give it another go :|