Reply to Re: How do I get exec() to display errors?

Your name:

Reply:


Posted by Jerry Stuckle on 07/08/06 01:26

Robert S wrote:
> I would like to display error messages put out by shell commands. For
> example the following code gives no output and the array $output has no
> values:
>
> <?php
> exec( 'lss', $output );
> var_dump( $output );
> ?>
>
> ..assuming that I don't have an executable called 'lss' on my computer.
>
> The equivalent on the command line displays the error message:
>
> # php -r 'exec( "lss", $output );'
> # sh: lss: command not found
>
> How do I get the exec() command to display errors?
>
> I've tried `exec( 'lss 2> /dev/stout', $output );' with no success.
>

2> redirection is a shell function, not the OS. You'll need to use
shell_exec() to allow the redirection.

Also, the syntax should be 2>&1. That way if stdout is also redirected
stderr will follow.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация