|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-01-22 10:23 UTC] samleejboss at gmail dot com
Description:
------------
A parsing/execution problem is taking place when a command, such as "php test.php", runs a script which contains the command ("php test.php") within a string.
It seems the problem can also be recreated when the string is manipulated, like base64 decoded.
Test script:
---------------
<?php
echo shell_exec("ps aux|grep php test.php");
?>
Expected result:
----------------
root 9641 0.0 0.1 162544 10036 pts/0 S 12:19 0:00 php test.php
Actual result:
--------------
<?php
echo shell_exec("ps aux|grep php test.php");
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 07:00:01 2025 UTC |
This doesn't look like a bug to me. You are trying to pass the string "php test.php" to grep, but since you didn't put quotes around it, you are asking grep to look for the string "php" in a file named "test.php". You need something like this: echo shell_exec("ps aux|grep \"php test.php\"");