pexpect 在不同窗口中的输出
现在我正在一个项目中工作,其中测试脚本必须连接许多(3-10)台远程计算机(SSH 并执行一些操作)。 我开始使用 pexpect,它就像一个按钮一样简单。效果很好。
我想看看测试期间的通信。我知道可以将日志重定向到屏幕。但在这种情况下,日志(来自不同计算机)是混合的。 我想要的是为每个新的生成对象打开新的终端窗口(或控制台或其他)。在这种情况下,我可以在不同的窗口中看到所有通信。另外,我想在每个窗口中保留spawn.interact()的可能性。 我觉得这是可能的,但我不知道如何。我认为一些文件指针(或管道)应该以某种方式传递到新窗口(?) (SecureCRT 知道这样的事情,它有选项卡式控制台窗口,可以单独访问它们,但它是一个商业产品)
或者让我让问题更简单。 如果这样做,我可以在新窗口中打开一个新 shell:
p=Popen(["cygstart", "bash"])
如何从我的脚本读取和写入此 shell (家长)在这个新窗口中看到它?
如果你们中有人能指出我正确的方向,我将不胜感激。
如果你告诉我要阅读或查找什么(在谷歌上)就足够了,因为我没有发现任何人遇到此类问题。 环境是cygwin。
预先感谢
br:drv
Now I am working in a project where the testscript has to connect many (3-10) remote computers (SSH and do some stuff).
I started to use the pexpect and it is simple as a button. It works fine.
I want to see the communication during test. I know it is possible to redirect the log to the screen. But in this case the logs (from different computer) are mixed.
What I would like is to open new terminal window (or consol or whatever) for every new spawn object. In this case I could see all communication in different windows. Additionally I would like to keep the possibility of spawn.interact() in every window.
I feel that it is possible somehow but I don't know how. I think some file pointer (or pipe) should pass to the new window somehow(?)
(SecureCRT knows sometihng like this, it has tabbed consol windows and can access them separately, but it is a commercial product)
Or let me make the problem more simple.
If I do this, I can open a new shell in a new window:
p=Popen(["cygstart", "bash"])
How can I read and write into this shell from my script (parent) to see it in this new window?
I would really appreciate it, if one of you could point me in the right direction.
It is enough if you tell me what to read or find for (on Google) because I did not find anybody such kind of problem.
The environment is cygwin.
Thanks in advance
br:drv
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试过使用日志文件参数?
这将自动记录到文件的所有通信,包括您在调用spawn.interact()后输入的命令
更多信息可在网站上获得:http://pexpect.sourceforge.net/pexpect.html
搜索“日志文件”以查找相关文档。
Have you tried using the logfile parameter?
This will automatically log all communication to the file, including commands you enter after calling spawn.interact()
More info available on the website: http://pexpect.sourceforge.net/pexpect.html
Search for 'logfile' to find the relevant documentation.