Tuesday, February 6, 2024

[SOLVED] bash + how to avoid specific messages in the log file

Issue

when I run the bash script on my Linux machine we get the following errors in my log ,

note - we set in the script:

exec > $log 2>&1 ,  (  in order to send all standard error/output to $log ) 

the errors messages:

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

in order to filter this errors messages we try to set in the bash script that:

export TERM=xterm

but without help

after digging we found that happened in some case for example when we perform ssh to remote machine and runs commands on remote machine VIA ssh

in order to avoid that we set TERM=xterm in the bash script as the following:

ssh user@$remote_machine "TERM=xterm  /tmp/script.sh"

but it’s very not elegant solution and because my script use a lot of ssh and curl command then it’s not practical solution to set this on each SSH or curl etc

so my big question is

how to filter the message – tput: No value for $TERM and no -T specified ?

so we not get these ugly message in my $log file


Solution

Filter out all tput: No value from logging:

exec > >(grep -v 'tput: No value for $TERM and no -T specified' >$log) 2>&1


Answered By - Bach Lien
Answer Checked By - Marie Seifert (WPSolving Admin)