0
_stdin, _stdout,_stderr = client.exec_command("top -c")   
print(_stdout.read().decode())  
print(_stderr.read().decode())
client.close()

output: TERM environment variable not set.

i am not getting top command output, please help in advance.

2 Answers2

0

try code shown below,

_stdin, _stdout,_stderr = client.exec_command("export TERM=xterm \n top -c")   
print(_stdout.read().decode())  
print(_stderr.read().decode())
client.close()
  • Throwing error . top: failed tty get – Amarendhiran Amar Jun 06 '23 at 16:46
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 07 '23 at 00:40
0

Try to use get_pty=True

_stdin, _stdout, _stderr = client.exec_command('top -c', get_pty=True)
while buffer := _stdout.read(4096):
    print(buffer.decode())
Philippe
  • 20,025
  • 2
  • 23
  • 32