0

This is the code that I want to execute through motd:

#!/bin/bash
IP=`ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`
#clear
echo -e "Welcome to \e[0;32mDMS 4\e[0m"
echo
echo -e "Connect with your Browser to following IP-Address: \e[0;32mhttp://$IP\e[0m"
echo
echo "If no IP-Address is shown above then"
echo "maybe there is no DHCP-Server available in your network."
echo "If so you have to change the IP to a static Address."
echo -e "Just type \e[0;32mnetconf\e[0m and press Enter"

I placed /usr/sbin/autologin-screen (location of the script) in my 00-header file under the /etc/update-motd.d folder.
Does anyone have an idea why I am getting this error:

TERM environment variable not set

Note* Removing Clear removed 1 error. I still have another TERM environment variable not set

Keith
  • 227
  • 4
  • 13
  • What does clear and shift and exec $* do? – Tim Jul 28 '14 at 12:17
  • @Tim I forgot, I do not actually use those lines, they were specific to another distro. I edit them out of my initial post. See what copy paste does lol. – Keith Jul 28 '14 at 12:23
  • And the clear is suppose to clear the terminal screen. – Keith Jul 28 '14 at 12:23
  • @Keith - you could just take out the cat /etc/issue line... (why is that needed anyway?). – Wilf Jul 28 '14 at 12:28
  • @Wilf Just wanted to display the issue, but it does already display it on boot. Taking it out however did not fix the TERM enviroment issue. – Keith Jul 28 '14 at 12:33

1 Answers1

2

According to motd manual:

   The  contents of /etc/motd are displayed by login(1) after a 
   successful login but just before it executes the login shell.

according to login manual:

   On some installations, the environmental variable $TERM will be
   initialized to the terminal type on your tty line, as specified in
   /etc/ttytype.

and according to clear manual:

   It looks in the environment for the terminal type and then in the
   terminfo database to  figure out how to clear the screen.

I guess that TERM variable is set after your motd scripts execution and because of this, clear command print TERM environment variable not set.

On lubuntu 12.04 I tested this by unset TERM and exec clear. In this condition I obtain same error.

Lety
  • 6,039
  • 2
  • 29
  • 37
  • Removing the clear command did remove a TERM enviroment variable not set. I did however have that error pop up twice and I still have one left. I will look into something else maybe creating the problem. – Keith Jul 30 '14 at 12:17
  • I don't think that your motd script prints that error now. Could you check file in /etc/update-motd.d directory ? Also .bashrc, .profile. Once you are logged in, is $TERM correctly set? try echo $TERM – Lety Jul 30 '14 at 17:12
  • echo $TERM prints linux. Is this correct. I am going to look into those other files now. – Keith Jul 30 '14 at 17:19
  • I found where the error was. In my 00-header file I had a clear. Commented it out and it works fine now. Thanks for the tips! – Keith Jul 30 '14 at 17:22
  • linux value is right if you are using getty. Here is some useful information. – Lety Jul 30 '14 at 17:23