I am using pxssh to run commands on the server, however the code I have prints the command I am running to a wx.multiline box; however I don't want to print the command I am running only the response.
Is there a way to only print out the output of the command using pxssh?
def runCmd(self, command):
try:
s = pxssh.pxssh()
s.login("127.0.0.1", "root", sshPass)
s.sendline(command)
s.prompt()
stdout = s.before
s.logout()
return stdout
except pxssh.ExceptionPxssh as e:
self.progressBox.AppendText(str(e))
I'm assuming this is functionality built into the pxssh code for sendline/prompt, but is there a way to override printing the command on a case by case basis?
Can't believe no one knew an official pxssh answer to this.
The way round I found was to split the output into lines, and then only print the output of the line that you want.
This removes all the other stuff including the command:
for line in stdout.split("\n"):
if "DONE:" in line:
print line