Linux Mint .profile TERM variable not set

0

1

I have a custom script in my .profile file, with added code and nothing taken away, however it is still replying with a TERM ENVIRONMENT VARIABLE NOT SET error. However, if I run the command echo $TERM in the terminal after boot it is set to xterm-256color. I'm open to even suppressing the error instead of solving it since it does not effect my computer after the boot.

Here is the script in .profile:

clear
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi


# --- EVERYTHING ABOVE HERE IS DEFAULT AND NOT CHANGED ---


wget -q --spider http://google.com
if [ $? -eq 0 ]; then
    (
     echo )
    else
    (
    echo Aquiring Internet Connection . . .
    sleep 6)
    fi
wget -q --spider http://google.com
if [ $? -eq 0 ]; then
    (
     echo )
    else
    (
    sleep 5)
    fi

wget -q --spider http://google.com
if [ $? -eq 0 ]; then
    echo ==========================================================================================================================================
    echo WELCOME LUKAKA                                     LOCAL WEATHER REPORT    VIA WTTR.IN                                      Running XFCE
    echo ==========================================================================================================================================
    curl wttr.in
    echo ==========================================================================================================================================
    echo
    echo -e "\033[1;32mStatus for play.wildcraftmc.com [Wildcraft Survival+ Server]   \033[0m" 
    mcstatus play.wildcraftmc.com status >wildcraft.txt
    sed -n 1p wildcraft.txt
    tail -n -1 wildcraft.txt
    echo ==========================================================================================================================================
    echo -e "\033[1;32mStatus For Mc.Starlegacy.Net [Starlegacy Space Survival]   \033[0m" 
    mcstatus mc.starlegacy.net status >Star-Legacy.txt
    sed -n 1p Star-Legacy.txt
    tail -n -1 Star-Legacy.txt
    echo ==========================================================================================================================================
    echo -e "\033[1;32mStatus For Jectile.com [Shoota COD Server]   \033[0m" 
    mcstatus Jectile.com status >Star-Legacy.txt
    sed -n 1p Star-Legacy.txt
    tail -n -1 Star-Legacy.txt
    echo ==========================================================================================================================================
    rm Star-Legacy.txt
    rm wildcraft.txt
else
    echo Connection Failed.
fi

echo -n "Would you like to start the GUI (y/n)? "
old_stty_cfg=$(stty -g)
stty raw -echo ; answer=$(head -c 1) ; stty $old_stty_cfg # Careful playing with stty
if echo "$answer" | grep -iq "^y" ;then
    sudo systemctl start lightdm
    onedrive-d start
    xinput set-prop 11 317 -1
else
    echo No
    echo -e "\033[0;33mskipping GUI. The following service(s) will not run: onedrive-d, lightdm, Minecraft-Lukaka, xinput 11.\033[0m"
    fi

This is the error message: err\

For context, what my script does is check for an internet connection, if it is there it wgets wttr.in (weather) and uses an official Minecraft tool to check the status on some servers.

Mark Deven

Posted 2018-08-09T14:32:26.363

Reputation: 1 101

Answers

1

So once your script gets to the point where it asks you if you want to start the GUI, if you say yes it runs 3 more commands:

sudo systemctl start lightdm

onedrive-d start

xinput set-prop 11 317 -1

Now, if you know the errors are harmless, you can redirect them into nothingless using 2>/dev/null after the command causing the error, such as

sudo systemctl start lightdm 2>/dev/null

However, it'd be more advisable to run each of these commands in turn, review the errors that show and fix them if possible.

djsmiley2k TMW

Posted 2018-08-09T14:32:26.363

Reputation: 5 937

I did add the error message if that helps. I also don’t get any errors when running it in terminal. – Mark Deven – 2018-08-09T14:48:58.680

That script is horrifically hacky and doing all sorts of 'bad' things. I don't even know where to go from here. – djsmiley2k TMW – 2018-08-17T11:56:50.553

How so? I was trying to find the best way to do all of these things but I'm not an expert basher. I'm used to Windows Batch. – Mark Deven – 2018-08-17T12:01:28.563

1

You should check whether you're running in a terminal before printing messages or running commands that require a terminal. This can be done, for example, using:

if [ -t 1 ] # check if stdout is a terminal
then
  # in a TTY, do stuff
fi

THe GUI login process sources /etc/profile and ~/.profile so that any environment variables you may need are set. But this sourcing isn't done in a terminal, so TERM isn't set. When you open a terminal, and run echo $TERM, the terminal has set TERM for processes started by it, so you get a value.

IMO you should wrap all of whatever you added in the if check given above, since none of it is particular relevant when running in a GUI.

muru

Posted 2018-08-09T14:32:26.363

Reputation: 975

Very smart I hadn't thought of that thank you! Will it still work even though there are other if/fi checks inside my script? – Mark Deven – 2018-08-19T11:54:31.477

1@MarkDodsons you can nest if blocks inside another if block – muru – 2018-08-19T13:57:01.493