Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Your Answer


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.