Skip to main content
Question

Log from Bash Script

  • February 17, 2017
  • 3 replies
  • 14 views

anverhousseini
Forum|alt.badge.img+11

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

donmontalvo
Forum|alt.badge.img+36
  • Hall of Fame
  • February 18, 2017

Post script?


Forum|alt.badge.img+4
  • Contributor
  • February 19, 2017

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
Forum|alt.badge.img+11
  • Author
  • Valued Contributor
  • February 20, 2017

@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?