I'm having trouble getting an answer to my question, in laymens terms. It is probably my lack of knowledge on the subject so, I'm dumbing down the question. I have a windows machine that I run the putty tool from and connect to a linux box. I run " killall /bob/bin/myfile.out " then close putty then type in a cmd prompt pscp.exe myfilet.out.2.3.4 root@192.168.1.1:/bob/bin/myfile.out . Can someone show me how to combine these into a single windows batch file? thank you
Asked
Active
Viewed 2,232 times
2 Answers
1
You could use the free command line tool Plink to run commands on external servers via SSH.
@echo off
Plink root@192.168.1.1 "killall /bob/bin/myfile.out"
pscp.exe myfilet.out.2.3.4 root@192.168.1.1:/bob/bin/myfile.out || echo an error occurred when copying the file.
the command after ||
on the second line will only run if an error level is set by the previous command.

unclemeat
- 5,029
- 5
- 28
- 52
-
using putty to logon toa linux box, root@1.5.67.100 with -PW works great. But I cant get to this same location with plink so I can run the bat file or sh file. Any help would be appreciated. Thanks – user3314404 Mar 20 '14 at 00:05
0
I can't add comments yet, but can you elaborate on how you login with putty, but not do the exact same thing with plink? Plink not only accepts all the same options as putty, but if you have a saved session in putty, you can access it from plink. Without any subcommands, plink should essentially make you CMD shell look like a crude putty window, with subcommands, it will execute them and return:
C:\Users\riglerjo>plink savedputtysession
Using username "rigler".
# hostname
s9-chicago.accountservergroup.com
-bash-3.2$ exit
logout
Run the remote command as an option on plink:
C:\Users\riglerjo>plink savedputtysession hostname
s9-chicago.accountservergroup.com

John Rigler
- 183
- 1
- 7