0

It's strange that neither

ssh user@192.168.1.59 bash -c "top"

nor

ssh user@192.168.1.59 "top"

works as expected, whereas both

ssh user@192.168.1.59 "ls"  

and

ssh user@192.168.1.59 bash -c "ls"  

work well.

Here is the error message\output for the former command.

TERM environment variable not set.

I searched and found this post.

As per the said post, there is an answer shed some light on this matter.

You can see if it's really not set. Run the command set | grep TERM. If not, you can set it like that: export TERM=xterm

I tried

ssh user@192.168.1.59 bash -c "set | grep TERM;top"

, and the output is

TERM=dumb
TERM environment variable not set.

, which is in my expectation.

Then I try to set XTERM as what the post told me, but it does not work. I am stuck again. Here is my command to set XTERM and run top:

ssh user@192.168.1.59 bash -c "export TERM=xterm-256color; top"

Here is the output for the above command:

declare -x DISPLAY="localhost:13.0"
declare -x LANG="en_US.UTF-8"
declare -x LC_ALL="C"
#...
TERM environment variable not set.

Could somebody shed some light on this matter?

  1. why ssh user@192.168.1.59 "ls" works, whereas ssh user@192.168.1.59 "top" does not?
  2. why ssh user@192.168.1.59 bash -c "export TERM=xterm-256color; top" does not work, you see I set TERM indeed.
1
  • SSH doesn't allocate pseudo-terminal by default when given a command to run, which means top can't access your terminal to draw the interface, unlike a non-interactive program like ls. See also unix.stackexchange.com/a/48530/70524 With -t SSH allocates the pty, and sets TERM appropriately. Setting TERM doesn't help without the pty allocation.
    – muru
    Jun 14 at 13:34

0

Browse other questions tagged or ask your own question.