我正在尝试使用Unix服务器打开会话,然后将控件释放给脚本用户,直到按下Ctrl + y,之后程序应该控制我使用Eclipse和WinPython 2.7.这是代码
from Exscript.util.interact import read_login
from Exscript.protocols import SSH2
def Test ():
print "Interactive session closed"
account = read_login() # Prompt the user for his name and password
conn = SSH2()
conn.set_driver('generic') # We choose to use SSH2
conn.connect('remmotehostip') # Open the SSH connection
conn.login(account) # Authenticate on the remote host
conn.execute('uname -a') # Execute the "uname -a" command
print conn.response
conn.interact({'\031': Test()})
conn.send('exit\r') # Send the "exit" command
conn.close()
Run Code Online (Sandbox Code Playgroud)
以上失败了
Traceback (most recent call last):
File …Run Code Online (Sandbox Code Playgroud)