Re: exec, system , backtick
| From: | Michael Sims | Date: | Sat, 28 Dec 2002 02:01:09 +0000 |
| Subject: | Re: exec, system , backtick | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129483@lists.php.net to get a copy of this message | ||
On Sat, 28 Dec 2002 02:55:44 +0530, you wrote:
>I tried a simple command line script, in all cases no_file does not exist. I
>do not want the command line script to show the error on the screen but to
>deliver it in the variable $r. But alas, in all 3 cases i get 'rm: canoot
>remove `no_file': No such file or directory'
[script snipped]
I think this is because your error is being sent to stderr but PHP is
only capturing what is sent to stdout. I was able to acheive your
desired results by redirecting stderr to stdout via the shell. Try
the following, it worked for me:
#! /usr/bin/php -q
<?
$r =
rm no_file 2>&1;
echo "the value in r is $r";
?>
If you need more info on the "2>&1" part, consult the Advanced Bash
Scripting Guide here:
http://www.digitaltoad.net/docs/guide/advshell/io-redirection.html