Putty and commands

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Putty and commands

Post 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 :)
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

C:\Program Files\putty\plink.exe -pw mypassword user@example.com /bin/ls -la
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post 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 :|
Post Reply