note 108713 added to function.system
| From: | no at mail dot com | Date: | Sat, 19 May 2012 22:06:14 +0000 |
| Subject: | note 108713 added to function.system | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188085@lists.php.net to get a copy of this message | ||
This is for WINDOWS users. I am running apache and I have been trying for hours now to capture the
output of a command.
I'd tried everything that is written here and then continued searching online with no luck at
all. The output of the command was never captured. All I got was an empty array.
Finally, I found a comment in a blog by a certain amazing guy that solved my problems.
Adding the string ' 2>&1' to the command name finally returned the output!! This
works in exec() as well as system() in PHP since it uses stream redirection to redirect the output
to the correct place!
system("yourCommandName 2>&1",$output) ;
----
Server IP: 69.147.83.197
Probable Submitter: 94.71.116.218
----
Manual Page -- http://www.php.net/manual/en/function.system.php
Edit -- https://master.php.net/note/edit/108713
Del: integrated -- https://master.php.net/note/delete/108713/integrated
Del: useless -- https://master.php.net/note/delete/108713/useless
Del: bad code -- https://master.php.net/note/delete/108713/bad+code
Del: spam -- https://master.php.net/note/delete/108713/spam
Del: non-english -- https://master.php.net/note/delete/108713/non-english
Del: in docs -- https://master.php.net/note/delete/108713/in+docs
Del: other reasons-- https://master.php.net/note/delete/108713
Reject -- https://master.php.net/note/reject/108713
Search -- https://master.php.net/manage/user-notes.php