1

Is there away to combine this into one batchfile? This is a hand me down task, but I think I should be able to combine the two. Why open Putty once and then open another tool pscp? I just don't know the difference between putty and pscp? Any help or insite would be appreciated. Thank you.

C:\putty.exe, 192.168.1.1 -pw xxxx killall /bob/bin/myfile.out

Close putty

pscp.exe myfile.out.2.3.4 root@192.168.1.1:/bob/bin/myfile.out pw

Reboot target

user3314404
  • 79
  • 1
  • 2
  • 10
  • putty invokes a shell and gives you an interactive command prompt on the remote system. pscp is a file copy operation that piggybacks on an SSH connection, but does not give you the interactivity that the main putty does. – Marc B Feb 17 '14 at 03:18
  • So does C:\pscp.exe 192.168.1.1 -pw xxxx killall /bob/bin/myfile.out do the same exact thing? – user3314404 Feb 17 '14 at 03:27
  • no. the putty one is logging into the remote system and running "killall". the pscp one just copying a file from your machine to the remote machine. – Marc B Feb 17 '14 at 03:28
  • I'm trying to get this operation down to a batch file I don't need the shell is there a way to do this? I have a dozen of these that open a putty window and then pscp? – user3314404 Feb 17 '14 at 03:31

1 Answers1

2

No, putty is analagous to ssh and pscp to scp.

PuTTY provides the overall functionality as does SSH. However, ssh and putty (non-capitalized) are interactive (as well as non-interactive by supplying shell commands as arguments) command line interfaces within the greater context of what PuTTY and SSH can do. scp and pscp are secure versions of the ftp Linux/Unix command (with similar, but not identical, command sets) which use the SSH protocol to securely authenticate and transfer files.

So essentially, there is not a way to combine them. The Unix philosophy is that one tool does one thing and does it really well.

Joseph Myers
  • 6,434
  • 27
  • 36
  • Does plink enter into the equation anywhere? I can't beleive that I can't combine these. It seems so prehistoric. – user3314404 Feb 17 '14 at 03:35
  • Possibly `plink` could be used for many things (it is a backend to PuTTY functionality). But even if possible, it would take much more code to copy files with any sort of backend interface like `pscp` than using the `pscp` command which reduces the very complex process of copying files to a simple source and destination. I realize that you are trying to avoid making a separate connection to the server, but as far as I know, even if you did use `pscp`, there would still need to be a separate connection to transfer the file's contents because the first connection is connected to a remote shell. – Joseph Myers Feb 17 '14 at 03:41
  • Not trying to be thick headed here, but could I not C:\pscp.exe, 192.168.1.1 -pw xxxx killall /bob/bin/myfile.out and then pscp.exe myfile.out.2.3.4 root@192.168.1.1:/bob/bin/myfile.out pw I really want to avoid banging these commands out each time. – user3314404 Feb 17 '14 at 03:43
  • Is there a way to open putty and autoload the command killall /bob/bin/myfile.out – user3314404 Feb 17 '14 at 03:47
  • You should be able to run the whole thing from a batch file. Are you typing this out by hand or are these lines in a batch file? – Joseph Myers Feb 17 '14 at 03:49
  • oh no, I am having to bang these out by hand. I'm looking for a solution! – user3314404 Feb 17 '14 at 03:52
  • The PuTTY documentation explains how to set up private/public keys on your computer and place them in the `.ssh` directory of the server. Then you will not need to authenticate by hand for each connection and you can use both commands freely in batch files and never do any more repeated typing. – Joseph Myers Feb 17 '14 at 03:52
  • ignorant question, but why do I need the keys, that maybe the reason that this approach is being taken. – user3314404 Feb 17 '14 at 03:56
  • You can also just open a single SSH session to the server and type the `killall` commands into it without needing to close it every time. You can use another Command prompt for the `pscp` commands, although you will still have to type your password between each command unless you can figure out the keys. – Joseph Myers Feb 17 '14 at 03:57
  • Joseph, you have been a hugh resource, Could I as you to put this into a little simpler context,I'm clearly a nube here, open a single ssh session with pscp? and killall or still putty? – user3314404 Feb 17 '14 at 04:06