Ufuk Eskici wrote: > Hello, > > I changed my way. This time I'm using "plink" under Putty. > > My python code is: > > os.chdir("c:\\Program Files\\Putty") > cmd = "plink -ssh -l ufuk10.10.10.10 -pw password" > process = subprocess.Popen(cmd) > inputdata="r van" > result = process.communicate(inputdata) > > But after the successful SSH, I cannot continue, no command runs: > This is the new output after the initial SSH connection: > No data input. > > Last login: Fri Dec 21 16:27: > ufuk@home-ubuntu:~$
I am not familiar with plink, so I cannot help you. I recommend using an SSH module which help a lot with all of this. That being said, maybe this post will help: http://code.activestate.com/lists/python-tutor/74807/ Also take a look at the subprocess.communicate documentation[1] as it says """ Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. **Wait for process to terminate**. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child. communicate() returns a tuple (stdoutdata, stderrdata). Note that if you want to send data to the process's stdin, you need to create the Popen object with stdin=PIPE. Similarly, to get anything other than None in the result tuple, you need to give stdout=PIPE and/or stderr=PIPE too. """ (emphasis added) This suggests communicate is waiting for the plink to end? Also, you should probably pass in a pipe so that you can send data more than once. Note, I am not familiar with subprocess so YMMV. [1]http://docs.python.org/2.7/library/subprocess.html#subprocess.Popen.communicate Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy and completeness of information, viruses, confidentiality, legal privilege, and legal entity disclaimers, available at http://www.jpmorgan.com/pages/disclosures/email. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor