python - Using Subprocess and Communicate to execute commands on Telnet connection -


this first query on stackexchange. kindly excuse, if question been raised , answered. if so, kindly point me same.

query: trying establish telnet connection board , run app after that. capture both stdout , stderr during whole process. below snippet of code

code snippet:

import subprocess import time  #1. establish subprocess  commandlist = ["telnet"] + ["10.11.12.13"] p = subprocess.popen(commandlist,                      stdin = subprocess.pipe,                      stdout = subprocess.pipe,                       stderr = subprocess.pipe) #2. give login name. there no password p.stdin.write("root\r") #3. adding sync avoid overlap time.sleep(1) #4. invoke communicate execute application specied path on 10.11.12.13 system stdout, stderr = p.communicate('sh /mnt/path/app\r') 

at step (4), tried printing values of stdout , stderr see whether application 'app' has run or not. unfortunately, has not executed 'p.communicate()' line.

if 1 has encountered similar problem or know solution, kindly me fix issue.

thank you!!

terminate strings \n instead of \r?

consider using telnetlib, instead of rolling own w/ subprocess?

and finally, if can run ssh server on board, you'll able use paramiko , ssh channels, avoid headaches down road.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -