tput: No value for $TERM and no -T specified
I am making a code in bash and it does not execute correctly. I think it may be a bug found in the bashrc file .
#!/bin/bash
#Variables Globales
function Unconfirmedtransactions()
{
echo '' > ut.tmp
while [ "$(cat ut.tmp | wc -l)" == "1" ]; do
curl -s "$unconfirmed_transactions" | html2text > ut.tmp
done
hashes=$(cat ut.tmp | grep "Hash" -A 1 | grep -v -E "Hash|\- -|Time")
echo $hashes
tput cnorm
}
parameter_counter=0; while getopts "e:h:" arg; do
case $arg in
e) exploration_mode=$OPTARG;let parameter_counter+=1;;
h) helpPanel;;
esac
done
tput civis
Apparently the variable $TERM
has no value assigned.
tput
it needs a terminal where to display the output, and if you are launching your script, for example, throughcron
, it is executed as a userroot
without having a terminal assigned.You have some possible solutions:
Assign
TERM
to the valuedump
before calling liketput
so:TERM=dump
Assign
TERM
to the current value you have shown in the comments:TERM=xterm-256color
Pass it the parameter
-T
and specify a terminal, such as-T xterm-256color
tput -T xterm-256color cnorm
If you're running your script since
cron
then you could also put this at the beginning, substituting or<terminal>
in your case:dump
xterm-256color
Although the truth is that it does not seem appropriate to use it
tput
within a script that is not going to be executed in a terminal and perhaps you should check what you are using it for and if it will really fulfill your purpose.