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'm using a PHP script from cli, the script calls exec() a few times. There are some minor errors sometimes, which are handled by the PHP script. I'm suppressing the errors by appending 2>/dev/null to the end of each command...

Is there any way to achieve that without adding the aforementioned?

share|improve this question
Well, what are the errors? You could handle the errors in your php script so they don't appear at all. – user13742 Jun 9 '12 at 11:22

Not with exec(). You'd have to use proc_open() if you want to capture/suppress stderr.

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.