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?

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

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.