python交互模式切换_python – Exscript:如何在交互式会话和非交互式会话之间切换?...

我正在尝试使用Unix服务器打开会话,然后将控件释放给脚本用户,直到按下Ctrl y,之后程序应该控制

我正在使用

Eclipse和Win

Python 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()

以上失败了

Traceback (most recent call last):

File "C:\Users\mynamehere\Documents\Eclipse\ESNetworkDiscovery\TestInteractiveSession.py", line 20, in

conn.interact({'\031': Test()})

File "C:\Utils\WPy2.7-32\python-2.7.13\lib\site-packages\Exscript\protocols\SSH2.py", line 364, in interact

return self._open_shell(self.shell, key_handlers, handle_window_size)

File "C:\Utils\WPy2.7-32\python-2.7.13\lib\site-packages\Exscript\protocols\Protocol.py", line 1190, in _open_shell

return self._open_windows_shell(channel, key_handlers, handle_window_size)

TypeError: _open_windows_shell() takes exactly 3 arguments (4 given)

我究竟做错了什么 ?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值