Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何获得pxssh模块输出?_Python_Pxssh - Fatal编程技术网

Python 如何获得pxssh模块输出?

Python 如何获得pxssh模块输出?,python,pxssh,Python,Pxssh,我正在尝试使用pxssh发送命令 cmd1 = somecommand cmd2 = anothercommand cmd3 = cmd1 + cmd2 + hostname s.sendline(cmd3) print s.before 我只需要我的cmd输出,而不是cmd+输出。 s、 expect帮不上忙,因为它在模式之前剪切了输出,但在模式之后我需要一条消息。 谢谢。我知道这已经一个月了,但万一有人来,这应该会有帮助 由于要发送的命令位于输出中自己的行上

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

   cmd1 = somecommand
   cmd2 = anothercommand
   cmd3 = cmd1 + cmd2 + hostname
   s.sendline(cmd3) 
   print s.before
我只需要我的cmd输出,而不是cmd+输出。 s、 expect帮不上忙,因为它在模式之前剪切了输出,但在模式之后我需要一条消息。
谢谢。

我知道这已经一个月了,但万一有人来,这应该会有帮助

由于要发送的命令位于输出中自己的行上,因此可以执行以下操作:

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