术语环境变量未设置

术语环境变量未设置

这是我想要通过 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"

我将/usr/sbin/autologin-screen(脚本位置)放在00-header文件夹下的文件中/etc/update-motd.d
有人知道我为什么会收到此错误吗:

TERM environment variable not set

注意* 删除 Clear 可删除 1 个错误。我还有另一个TERM environment variable not set

答案1

根据mod 手册

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

根据登录手册

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

并根据清晰的手册

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

我猜 TERM 变量是在你的动态脚本执行,因此,清除命令打印TERM environment variable not set

在 lubuntu 12.04 上,我通过unset TERMand exec测试了这一点clear。在这种情况下,我得到了同样的错误。

相关内容