Saturday, May 4, 2024
6
rated 0 times [  6] [ 0]  / answers: 1 / hits: 2723  / 2 Years ago, fri, july 8, 2022, 3:49:28

I am using



ssh user@host top


to show the top output from "host", i am getting



TERM environment variable not set.


What is the solution?



How can i run top on "host" like that and see output?


More From » command-line

 Answers
4

top shows it's output on a terminal device, not on any standard stream (e.g. STDOUT/STDERR). As there is no terminal involved in the remote host when doing:



ssh user@host top


it's giving the error about the TERM environment variable not being set.



You need to allocate a pseudo TTY on the remote host using the -t option of ssh:



ssh -t user@host 'top'


Now you can send keys to top in the usual manner too e.g. q to quit, h for help etc.



This same solution goes for all programs that require a TTY to show output.






For the sake of completeness, you can allocate a pseudo TTY even if there is not local TTY involved, by using multiple -ts e.g.:



ssh -tt user@host 'top'

[#13351] Saturday, July 9, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
heathree

Total Points: 157
Total Questions: 132
Total Answers: 108

Location: Honduras
Member since Mon, Apr 5, 2021
3 Years ago
;