首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Exscript:如何在交互会话和非交互会话之间切换?

Exscript:如何在交互会话和非交互会话之间切换?
EN

Stack Overflow用户
提问于 2017-11-21 03:48:06
回答 1查看 295关注 0票数 6

我正在尝试以编程方式打开一个与Unix服务器的会话,然后将控制释放给脚本的用户,直到按下Ctrl+y,之后程序应该会控制我正在使用的Eclipse和WinPython 2.7。以下是代码

代码语言:javascript
复制
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() 

以上操作失败,并显示以下内容

代码语言:javascript
复制
     Traceback (most recent call last):
  File "C:\Users\mynamehere\Documents\Eclipse\ESNetworkDiscovery\TestInteractiveSession.py", line 20, in <module>
    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)

我做错了什么?

EN

回答 1

Stack Overflow用户

发布于 2017-12-14 08:27:23

看起来像是Exscript中的错误。

来自Protocol.py

代码语言:javascript
复制
        return self._open_windows_shell(channel, key_handlers, handle_window_size)
...
    def _open_windows_shell(self, channel, key_handlers):

该函数不接受第四个handle_window_size参数(careful about how python counts arguments in that situation)。

显然你没有使用最新的版本,但据我所知,即使是最新的版本也有bug。纵观源代码历史,我会说这个bug是在2.2引入的,而不是在2.1中。我没有测试过它,只是阅读了源代码,而且我不是python专家,所以我可能完全错了。

如果我是对的,你不能做太多,除了:

  • 使用2.1 (显然已有7年历史)
  • 在本地对其进行修补(可能会删除最后一个参数...不确定这会不会work!)
  • filing an issue
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47399913

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档