Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to "wrap" a process around another to catch stderr messages when they occur.

Use Case

I'm using Compass and I have to have a terminal open and see if there is something wrong. My plan is to use terminal-notifier tool to send myself OSX notifications so I notice an error happened. Then I don't have to keep terminal open on my screen all the time.

Imagine I have all this notification mechanism under a shell script named compass-error.sh which will send a notification when you call it. Now I want to run compass watch with my main process and watch for stderr to fire compass-error.sh. How do I do it?

share|improve this question

1 Answer 1

up vote 2 down vote accepted
output="$(./compass 2>&1 1>/dev/null)"
if [ -n "$output" ]; then
  echo "$output" | mail ...
fi
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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