Bug #63731 [Nab]: shell_exec() cannot run some commands

From: Date: Sun, 09 Dec 2012 12:05:01 +0000
Subject: Bug #63731 [Nab]: shell_exec() cannot run some commands
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-175235@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63731&edit=1

 ID:                 63731
 User updated by:    scott at smashcat dot org
 Reported by:        scott at smashcat dot org
 Summary:            shell_exec() cannot run some commands
 Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   Linux
 PHP Version:        5.4.9
 Block user comment: N
 Private report:     N

 New Comment:

Yep, was totally user error - output from $zip=which zip adds a linefeed which was not
being trimmed, so the command was sending zip to stdout. My bad! Removing...


Previous Comments:
------------------------------------------------------------------------
[2012-12-08 23:43:47] rasmus@php.net

Sorry, this has nothing to do with PHP. All PHP does is call popen() here which 
creates a pipe and forks a shell to run the command. To debug it try switching to 
your web server user id from the command line and trying it and if you are really 
stuck write a little popen() wrapper in C and try to figure out where it is 
failing. My guess is that it is a permissions issue.

------------------------------------------------------------------------
[2012-12-08 23:37:17] scott at smashcat dot org

Description:
------------
When attempting to call the zip command from php, it silently fails. Other commands to create and
delete files etc work fine. Using correct path to zip etc. No errors, just fails. Running same
command from terminal works.

Test script:
---------------
$zip=which zip;
$res=shell_exec("$zip test.zip test.txt");


Expected result:
----------------
zip file should be created

Actual result:
--------------
Nothing. No errors, although the response variable $res contains what appears to be part of the zip
file data. Seems like the output from zip is not going to the file, but being sent to the virtual
terminal.


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=63731&edit=1


Thread (3 messages)

« previous php.bugs (#175235) next »