2

我正在编写一个需要同时 ssh 和 telnet 到设备的应用程序。伪代码是这样的。

p1 = pexpect.spawn("ssh to the device")
p1.send("run some command")
p1.expect("..")

p2 = pexpect.spawn("telnet to same device")
p2.send("run a command that can be run only through telnet")
p2.expect("..")

p1.send("run some other command")
p1.expect("..")

p2.send("run another command that can be run only through telnet")
p2.expect("..")`

如果您注意到,我需要在两个 pexpect 孩子之间进行同步,以便一个接一个地运行它们。我搜索了很多,但找不到任何信息。请帮忙。谢谢

4

0 回答 0