0

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?

3

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).

  • Excellent, thanks very much. I'm pretty new to Shell Scripting, thanks again. – C0deAttack Sep 14 '11 at 16:33
3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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