Hallo, Vielen Dank.
Nun habe ich es so abgeändert:
Code: Alles auswählen
#ssh
s = pxssh.pxssh()
if not s.login ('localhost', 'myusername', 'mypassword'):
print ("SSH session failed on login.")
print (str(s))
else:
print ("SSH session login successful")
s.sendline ('uptime')
s.prompt() # match the prompt
print (s.before) # print everything before the prompt.
s.logout()
Nun erscheint ein andererer Fehler:
Code: Alles auswählen
s = pxssh.pxssh()
NameError: name 'pxssh' is not defined
Ups ich hatte import pxssh nicht Improtiert aber die Fehler gehen weiter -.-
Code: Alles auswählen
Rais ExeptionPxssh('could not synchronize with original prompt')
pexpect.pxssh.ExeptionPxssh: could not synchronize with original promt
Für alle die das Selbe Problem haben:
Mein Code:
Code: Alles auswählen
import pxssh
#ssh
s = pxssh.pxssh()
if not s.login ('192.168.61.93', 'root', 'schneider'):
print ("SSH session failed on login.")
print (str(s))
else:
print ("SSH session login successful")
s.sendline ('mpc play 3')
s.prompt() # match the prompt
print (s.before) # print everything before the prompt.
s.logout()
Achtung!!! Pytohn 3.2.3
Nun musste ich von pxssh (pexpect) folgende Datei ändern:
Code: Alles auswählen
/usr/local/lib/python3.2/dist-packages/pexpect/pxssh.py
Und zwar diese Zeile:
Code: Alles auswählen
# All of these timing pace values are magic.
# I came up with these based on what seemed reliable for
# connecting to a heavily loaded machine I have.
self.sendline()
time.sleep(0.1) # Hier neu: time.sleep(0.5) oder noch höher
Dies liegt wohl daran das die ssh Verbindung relative langsam ist.