Log from Bash Script

anverhousseini
Contributor II

Hi Jamf Nation

I have a bash script which has some special echo outputs like color, bold etc.

Unfortunately the logs are pretty weird. For example I see a lot of those errors:

tput: No value for $TERM and no -T specified
unable to write 'random state'

Anybody an idea what sort of error this is? The script is working correctly so I think this happens because of the echo commands.

3 REPLIES 3

donmontalvo
Esteemed Contributor III

Post script?

--
https://donmontalvo.com

john_bio
New Contributor III

A shell script I assume?

Do you have !#/bin/sh or !#/bin/bash at the top ?

Try switching it around and the $TERM error might go away.

It's saying it cant find a valid terminal to emulate

Could also try adding

export TERM=xterm

before any output is generated.

anverhousseini
Contributor II

@donmontalvo Unfortunately I can't post the entire script (internal policy) but here are some outputs where the errors occuring:

#!/bin/bash

bold=$(tput bold)
normal=$(tput sgr0) 
red=$(tput setaf 1)
green=$(tput setaf 2)
blue=$(tput setaf 4)

echo "${blue}==> ${normal} ${bold}Purge temporary directory${normal}"
echo "${red}Found MAS receipt${normal}"

@john_bio Yes it's shell and a #!/bin/bash at the top. Do you think I should use printf instead of echo?