php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60838 Output problem when script contains command
Submitted: 2012-01-22 10:23 UTC Modified: 2012-01-22 19:32 UTC
From: samleejboss at gmail dot com Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.3.9 OS: Debian Squeeze
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: samleejboss at gmail dot com
New email:
PHP Version: OS:

 

 [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");

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-22 19:32 UTC] rasmus@php.net
-Status: Open +Status: Bogus
 [2012-01-22 19:32 UTC] rasmus@php.net
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\"");
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 06:01:30 2024 UTC