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

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,089
  • 2
  • 32
  • 38