note 106250 added to function.shell-exec
| From: | trevatdedicate dot co dot uk at osu1 dot php dot net | Date: | Fri, 21 Oct 2011 14:34:11 +0000 |
| Subject: | note 106250 added to function.shell-exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-184045@lists.php.net to get a copy of this message | ||
If you're trying to run a command such as "gunzip -t" in shell_exec and getting an
empty result, you might need to add 2>&1 to the end of the command, eg:
Won't always work:
echo shell_exec("gunzip -c -t $path_to_backup_file");
Should work:
echo shell_exec("gunzip -c -t $path_to_backup_file 2>&1");
In the above example, a line break at the beginning of the gunzip output seemed to prevent
shell_exec printing anything else. Hope this saves someone else an hour or two.
----
Server IP: 69.147.83.197
Probable Submitter: 82.69.36.150
----
Manual Page -- http://www.php.net/manual/en/function.shell-exec.php
Edit -- https://master.php.net/note/edit/106250
Del: integrated -- https://master.php.net/note/delete/106250/integrated
Del: useless -- https://master.php.net/note/delete/106250/useless
Del: bad code -- https://master.php.net/note/delete/106250/bad+code
Del: spam -- https://master.php.net/note/delete/106250/spam
Del: non-english -- https://master.php.net/note/delete/106250/non-english
Del: in docs -- https://master.php.net/note/delete/106250/in+docs
Del: other reasons-- https://master.php.net/note/delete/106250
Reject -- https://master.php.net/note/reject/106250
Search -- https://master.php.net/manage/user-notes.php