[Tutor] ssh from Windows to a Solaris server
Steven D'Aprano
steve at pearwood.info
Tue Feb 21 01:25:40 CET 2012
Alan Gauld wrote:
> On 20/02/12 21:17, Do Nguyen (donguye) wrote:
>
>> command1 = "plink -ssh -pw myPassword myUserName at myServerIP"
>> p1 = subprocess.Popen(command1)
>> p2 = subprocess.Popen('ls')
>>
>> I could verify that command1 was executed successfully, ie. the ssh to
>> myServer worked, but command2 was treated locally in the Windows
>
> Yes, because you created a new subprocess.Popen object.
> If you want to communicate with ssh in the first subprocess you need to
> send commands to stdin on p1. There are lots of examples how to
> read/write to stdin/out in the subprocess documentation. (I'm assuming
> that plink stays open, I've never used it so don't know)
I don't know about plink, but the right way to run commands on a remote
machine using ssh is to give those commands to ssh as an argument. E.g.
http://linuxers.org/howto/how-run-commands-remote-machine-using-ssh
http://systemsboy.com/2006/07/send-remote-commands-via-ssh.html
--
Steven
More information about the Tutor
mailing list