0

I have the below code but it prints all the logs but I only want the last command log from the paramiko channel.recv()

#Unnecessary this output also comming/printing

  channel.send("python "+pycmd+"\n")
  channel.send("rm "+sys.argv[10]+"/"+py_file+"\n")

#The output of this command I need

     channel.send("cat "+sys.argv[16]+"\n")
     op_t=(channel.recv(1024).decode('UTF-8', 'ignore'))
     op_t_output = op_t.lower().replace("\r\n", " ").strip()
     print(op_t_output)

How can I get the last cat command out put only

Rajarshi Das
  • 11,778
  • 6
  • 46
  • 74
  • Hi Martin I need the file content output into the console via using cat command but it is not printing the file content...but it is printing the output of its previous commands – Rajarshi Das Dec 20 '21 at 08:51
  • Well, your code does not seem to try to read all output, it just reads the first at most 1024 bytes. And to read file contents, you better use SFTP anyway, not shell commands. – Martin Prikryl Dec 20 '21 at 09:06

0 Answers0