Search code examples
pythonpxssh

How to obtain pxssh module output?


I'm trying to use pxssh to send a command.

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

I need to take only output of my cmd not cmd + output. s.expect can't help because it cut the output before pattern but i need a messages after. Thanks.


Solution

  • I realize this is a month old, but in case others come here, this should help.

    Since the command being sent is on its own line in the output, you could do something like this:

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