Once you have done all this, you should be able to run a remote command on the SSH server machine and have it execute automatically with no prompting:
Z:\sysosd>plink login.example.com -l fred echo hello, world
hello, world
Z:\sysosd>
Or, if you have set up a saved session with all the connection details:
Z:\sysosd>plink mysession echo hello, world
hello, world
Z:\sysosd>
Then you can set up other programs to run this Plink command and talk to it as if it were a process on the server machine.
7.2.3 Plink command line options
Plink accepts all the general command line options supported by the PuTTY tools. See
section 3.8.3
for a description of these
options.
Plink also supports some of its own options. The following sections describe Plink's specific command-line options.
7.2.3.1 -batch: disable all interactive prompts
If you use the -batch option, Plink will never give an interactive prompt while establishing the connection. If the server's host key is invalid, for example (see
section 2.2
), then the connection will simply be abandoned instead of asking you what to do next.
This may help Plink's behaviour when it is used in automated scripts: using -batch, if something goes wrong at connection time, the batch job will fail rather than hang.
7.2.3.2 -s: remote command is SSH subsystem
If you specify the -s option, Plink passes the specified command as the name of an SSH ‘subsystem’ rather than an ordinary command line.
(This option is only meaningful with the SSH-2 protocol.)
7.3 Using Plink in batch files and scripts
Once you have set up Plink to be able to log in to a remote server without any interactive prompting (see
section 7.2.2
), you can
use it for lots of scripting and batch purposes. For example, to start a backup on a remote machine, you might use a command like:
plink root@myserver /etc/backups/do-backup.sh
Or perhaps you want to fetch all system log lines relating to a particular web area:
plink mysession grep /~fred/ /var/log/httpd/access.log > fredlog
Any non-interactive command you could usefully run on the server command line, you can run in a batch file using Plink in this way.
7.4 Using Plink with CVS
To use Plink with CVS, you need to set the environment variable CVS_RSH to point to Plink: