The Deployer

June 2, 2008

Linux I/O Redirection

Filed under: Linux — Lucian Daniliuc @ 14:26

Redirecting the output is useful everywhere, including in php.

By using `exec()` to import a .sql file into mysql, everything goes smoothly. Until you get some errors. Mysql sends the errors it encounters to stderr instead of stdout.

So… you get the command status 1 (something went bad), but no error message, so you don’t even know where to start.

That’s where the linux I/O redirections t come in handy.

To get the error message as well into the output, you have to add the following extra stuff to the end of your command line that is being passed to `exec()`:

2>&1

Now you also get the error messages in your response.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress