Reputation: 725
I'm trying to execute a command through system() in PHP. The command is /usr/bin/unzip, but the function returns with the error code 127. There is nothing else outputted. If I run the very same command directly in a shell it works.
The apache error log says 'sh: /unzip: not found'. I have also tried to put the command into a shell script that is in the same directory as the PHP script and call the shell script through system(). The same happens: if the shell script was called 'doit.sh' the error message in the apache log would be 'sh: /doit.sh: not found'.
exec() has the same behaviour.
The PHP version is 5.2.11-2 with suhosin extensions.
Any ideas what PHP could be doing to my command?
Upvotes: 0
Views: 338
Reputation: 2593
Turn off safe mode in php.ini.
If safe mode is on and the safe_mode_exec_dir
property is empty you'll get exactly the same behaviour as described.
Upvotes: 0
Reputation: 88796
Rather than shelling out to unzip things, you could just use PHP's zip functions.
Upvotes: 4
Reputation: 152216
Maybe try just with command name ?
system('unzip somestuff', $retval);
Upvotes: 1
Reputation: 48357
It looks as if you are sending the command 'unzip' when you should be using '/usr/bin/unzip'
If not, then, have you checked if your webserver runs in a chroot environment?
C.
Upvotes: 3