From: Julian Schaefer-J. <jul...@t-...> - 2002-06-04 18:26:18
|
Hi, I recently found myself confronted w/ the problem of remote-controling ssh. Several approaches w/ popen failed due to password-prompt. When I found your script I tried it - but it didn' t seem to work for me... obviously I must be doing something wrong... TheAddicT@siddhartha:~/swt-miles/proto/engine/ssh> python pyssh.py command="top -n 0" host=localhost password=<passwd> debug=1 >> child says: "TheAddicT@localhost's password: " >> child took 9 password bytes >> sleeping 0 secs >> child took 9 command bytes >> child response is '2dAKi4xs\r\n\r\ntop -n 0\r\n' results = '<passwd>\r\n\r\ntop -n 0\r\n' I use linux 2.4 Ssh: OpenSSH_2.9p2, SSH protocols 1.5/2.0, OpenSSL 0x0090602f Any hints would be greatly appreciated. I really don' t see what I am missing here. This is what I understand as the most minimalistic version of your script. Maybe it is obvious here where my problem lies: #!/usr/bin/python import os import sys import pty pid, fd = pty.fork() if pid == 0: os.execv("/usr/bin/ssh localhost", [""]) sys.exit() else: #print os.fstat(fd) os.write(fd, '<passwd>\n') os.write(fd, 'top -n 0\n') print os.read(fd, 1024) thanks In advance... julian |