Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch mode SSH gives error "TERM environment variable not set"

Tags:

linux

ssh

I made sure that TERM was defined in the .bashrc.

However, when running ssh in batch mode I get:

 $ ssh pc-lab7 "echo $TERM; echo $0"
    TERM environment variable not set.
    linux
    -bash

If I run ssh in interactive mode, I do not see this error.

How can I eliminate this error message?

like image 662
YoramW Avatar asked Apr 08 '12 14:04

YoramW


2 Answers

Use of -t option to ssh allocates tty

 -t      Force pseudo-tty allocation.  This can be used to execute arbitrary
         screen-based programs on a remote machine, which can be very useful,
         e.g. when implementing menu services.  Multiple -t options force tty
         allocation, even if ssh has no local tty.
like image 161
Thamme Gowda Avatar answered Nov 17 '22 03:11

Thamme Gowda


I finally found the reason for this annoying "TERM environment variable not set" warning.

It turned out that when the ssh is executing in batch mode without an interactive user, a call to 'clear' command in a startup script will yield this error.

Commenting out the 'clear' line in the script fixed the issue for me.

like image 7
YoramW Avatar answered Nov 17 '22 05:11

YoramW