Search code examples
linuxwindowsautomationputty

Automating running command on Linux from Windows using PuTTY


I have a scenario where I need to run a linux shell command frequently (with different filenames) from windows. I am using PuTTY and WinSCP to do that (requires login name and password). The file is copied to a predefined folder in the linux machine through WinSCP and then the command is run from PuTTY. Is there a way by which I can automate this through a program. Ideally I would like to right click the file from windows and issue the command which would copy the file to remote machine and run the predefined command (in PuTTy) with the filename as argument.


Solution

  • There could be security issues with common methods for auto-login. One of the most easiest ways is documented below:

    And as for the part the executes the command In putty UI, Connection>SSH> there's a field for remote command.

    4.17 The SSH panel

    The SSH panel allows you to configure options that only apply to SSH sessions.

    4.17.1 Executing a specific command on the server

    In SSH, you don't have to run a general shell session on the server. Instead, you can choose to run a single specific command (such as a mail user agent, for example). If you want to do this, enter the command in the "Remote command" box. http://the.earth.li/~sgtatham/putty/0.53/htmldoc/Chapter4.html

    in short, your answers might just as well be similar to the text below: