Terminal TERM issue

So, I am using Mac OSX(10.9.5) Darwin, when I connect to my server remotely via SSH and then "clear" commands give me error " TERM not set".

I thought this error is from the server side, also then when I connected to MySQL on executing queries/commands i got empty/blank output.

again thought its maybe a bug in debian(server) or MySQL until today.


I logged into server using PuTTY from a windows device and everything worked well. I was able to use clear command, and even MySQL is giving output, again when I logged in using terminal(Mac OSX) I faced same issues.


here is my .profile content:


MacBook-Pro:~$ cat ~/.profile


# MacPorts Installer addition on 2014-11-05_at_22:40:13: adding an appropriate PATH variable for use with MacPorts.

export PATH="/opt/local/bin:/opt/local/sbin:$PATH"

# Finished adapting your PATH environment variable for use with MacPorts.



Any suggestions? I am not sure why am I facing this issue.

MacBook Pro with Retina display, OS X Mavericks (10.9.5)

Posted on Jun 15, 2015 3:41 AM

Reply
4 replies

Jun 15, 2015 6:44 AM in response to FairyTale000

ssh can pass over a TERM environment variable, but it does not have to (and of course if your ssh client system does not have a TERM, there is nothing to pass). PuTTY I think does pass a TERM


You can always provide your own TERM (although it is often better if the client has a useful TERM as it is hoped that client has an idea as to what kind of terminal emulator it is using).


export TERM=xterm # this is generally a very safe choice.


But if you like using colors, then you could try one of these (of course your terminal emulator must support the number of colors indicated).

xterm-color

xterm-16color

xterm-88color

xterm-256color


I am using xterm-256color myself, which gives me a much richer Vim syntax coloring environment.


If you know you are going to use a specific TERM value every time you login from the system where you do not inherit a TERM value, you can always put something into your .profile

if [[ -z "${TERM}" ]]; then

export TERM=xterm-color

fi

Jun 17, 2015 4:20 AM in response to BobHarris

Did not work.


MacBook-Pro:~ $ export TERM=xterm

MacBook-Pro:~ $ echo $TERM

xterm

MacBook-Pro:~ $ ssh -p 22 -T root@************ bash -i

The authenticity of host )' can't be established.RSA key fingerprint is .Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added (RSA) to the list of known hosts.

root@ password: bash: cannot set terminal process group (-1): Invalid argument

bash: no job control in this shell


root@:~# clear

clear

TERM environment variable not set.

root@:~#

Jun 17, 2015 6:04 AM in response to FairyTale000

You have to issue the export TERM=xterm on the REMOTE system. The Mac already has a valid TERM, unless your remote system has a very limited set of TERM values.


When you login to the remote system you look to see what TERM it thinks it has by default:

echo $TERM

It might be the one you passed from your system, or it might be some other value. You can easily experiment by setting different local TERM values and see if they appear on the remote system. That would tell you if ssh is passing your TERM environment variable to the remote system.


The next thing to do is see what TERM values the remote system supports. This is a fun game as you have to figure out where the remote system stores its terminfo files. Typically it is something like

/usr/share/terminfo/...

And then you have to figure out where under the 'terminfo' directory the different TERM files are stored. The Mac has a bunch of numbered sub directories, I've seen on some Unix platforms a bunch of first letter subdirectories. It all depends on how the remote system's OS has decided to store the terminfo files.


Unless of course this system is so old that it uses a TERMCAP database. Wouldn't that be fun.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal TERM issue

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.