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.
Putty facilitates a connection type range to select from Serial, SSH, Rlogin, Telnet, and Raw. Also, it ships along with various tools of the command-line for DSA and RSA key generator (also known as puttygen), SFTP (psftp), SCP (pscp), etc, which can be executed from the terminal.
Syntax for running commands on a remote Linux or Unix hostssh : The ssh (or other SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. USER-NAME : Remote host user name. REMOTE-HOST : Remote host ip-address or host name, such as fbsd.cyberciti.biz.
Putty usually comes with the "plink" utility.
This is essentially the "ssh" command line command implemented as a windows .exe.
It pretty well documented in the putty manual under "Using the command line tool plink".
You just need to wrap a command like:
plink root@myserver /etc/backups/do-backup.sh
in a .bat script.
You can also use common shell constructs, like semicolons to execute multiple commands. e.g:
plink read@myhost ls -lrt /home/read/files;/etc/backups/do-backup.sh
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With