Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Plink batch file - Problem sending commands

1,429 views
Skip to first unread message

Nigel Butler

unread,
Aug 31, 2004, 6:06:39 AM8/31/04
to
I have successfully created a batch file to connect to a remote Unix
computer using Plink from a windows PC.
Once connected I want the batch file to send some commands to the
remote computer to change the directory and to start analysis on a
certain file.

The batch file I am using is as follows:
__________________________________
cd C:\Plink
plink user...@computer.com -pw mypassword

__________________________________

This connects fine, and I can then type my commands by hand into the
CMD window ...

cd dirname ... change the Dir
abq641 job=jobname input=jobname... run the analysis

all works fine. However I am trying to get the batch file to execute
these commands for me, but I cannot get it to work. I have tried the
following

__________________________________
cd C:\Plink
plink user...@computer.com -pw mypassword
cd scratch
abq641 job=jobname input=jobname
__________________________________

but this does not execute the commands, it logs in fine and then stop
after the second line.

I have also tried
__________________________________
cd C:\Plink
plink user...@computer.com -pw mypassword -batch cd scratch
abq641 job=jobname input=jobname
__________________________________

but this does not even log in... it just closes the CMD window.

All works fine if I type the command in by hand, but I cannot get the
batch file to do it for me!! Please can any one offer me any help or
advice in this matter.

Regards

Nigel

Richard E. Silverman

unread,
Aug 31, 2004, 7:19:31 AM8/31/04
to

> all works fine. However I am trying to get the batch file to execute
> these commands for me, but I cannot get it to work. I have tried the
> following
>
> __________________________________
> cd C:\Plink
> plink user...@computer.com -pw mypassword
> cd scratch
> abq641 job=jobname input=jobname
> __________________________________
>
> but this does not execute the commands, it logs in fine and then stop
> after the second line.

Of course. The computer is not going to magically do what you want just
because you arrange the commands so they appear on the screen in a
suggestive order. :) You want plink to execute those commands on the
remote host, but you have done nothing to arrange that; you have put them
in the local batch file instead. They will be executed on the local
computer, after plink exits (having done nothing), just like any other
command you put in that file.

Place the commands you want run on the remote host in a separate file
foo.sh, and run "plink -batch ... foo.sh".

http://www.tartarus.org/~simon/puttydoc/Chapter7.html#S7.3

--
Richard Silverman
r...@qoxp.net

0 new messages