pythonlinuxtop-command

paramiko python script for linux command execution


_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.


Solution

  • 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())