Serge
Serge

Reputation: 741

Strange output of bash script

I have bash script successfully running on CentOS 6 as cron

sh /a/mem1.sh >/a/mem1.txt; if [ -s /a/mem1.txt ] ; then mail -s "Server Low Memory" < /a/mem1.txt [email protected] ; fi

but under CentOS 7 it also successfully works as cron - but issues a strange 3-line additional output

tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified

So I receive two emails - one with normal script output as should be and another email with the strange outputs as above

I checked line-by-line the script commands inside - everything works without any errors or warnings. Google did not help a lot. Thanks in advance for a hint what it could be and how to solve it.

Upvotes: 0

Views: 148

Answers (1)

Etan Reisner
Etan Reisner

Reputation: 80992

Something is running tput in that script (presumably to colorize output when it can) and CentOS 7 clearly has no TERM value set in the cron environment so tput is complaining about it.

Either remove the calls to tput from the script or set a value for TERM for that process via cron or add the -T flag to the calls to force a particular term type.

Upvotes: 2

Related Questions