I have a shell script with the following:

STATUS=`/home/scripts/200check.sh $RUOK_URL`

Inside of 200check.sh I have some echo commands, but these commands are not displayed in the terminal. I guess they're consumed by something else?

Does anyone know how I can have the echo commands displayed?

link|improve this question
feedback

2 Answers

up vote 3 down vote accepted

echo outputs messages to stdout, and they are captured by the very same ` ` operator.

It's standard practice to send warnings or error messages to stderr instead. In bash, you would use:

echo "warning: blah" >&2

stderr is normally not affected by pipes or command substitution operators (although it can still be redirected).

link|improve this answer
Excellent, thanks very much. I'm pretty new to Shell Scripting, thanks again. – C0deAttack Sep 14 '11 at 16:33
feedback

The output from the script is saved in the $STATUS variable because you invoke it using back-ticks (a nicer way of doing it would be to use $(...), which nests easier). Try displaying the value of $STATUS to see if your expected output is there.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.