【问题标题】:How to obtain pxssh module output?如何获取 pxssh 模块输出?
【发布时间】:2020-06-17 23:09:25
【问题描述】:

我正在尝试使用 pxssh 发送命令。

   cmd1 = somecommand
   cmd2 = anothercommand
   cmd3 = cmd1 + cmd2 + hostname
   s.sendline(cmd3) 
   print s.before

我只需要输出我的 cmd 而不是 cmd + 输出。 s.expect 无能为力,因为它在模式之前削减了输出,但之后我需要一条消息。 谢谢。

【问题讨论】:

    标签: python pxssh


    【解决方案1】:

    我知道这已经一个月大了,但如果其他人来这里,这应该会有所帮助。

    由于正在发送的命令在输出中单独一行,您可以执行以下操作:

    output = s.before
    output = output.split('\r\n')
    output = output[1:]
    

    【讨论】:

      猜你喜欢
      • 2017-05-27
      • 2017-05-05
      • 2014-02-24
      • 2018-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-31
      • 2016-08-03
      相关资源
      最近更新 更多