[PHP] Having trouble with PHP exec function calling CGI program
Hello list members I'm a newbie and having trouble with the EXEC function call from a PHP script. I've submitted this problem to the list last week but so far no response. And I still haven't figured it out. So here goes again. PHP EXEC function seems to work ok for executing shell commands like 'ls -al' etc. but when I execute the following PHP web page code... -- $basedir = '/mnt/web/xxx/myplace'; $cdir = $basedir . '/cgibin'; $cmd = cd $cdir;pwd;perl -w myscript.cgi; echo cmd: $cmdbr; $result = exec($cmd,$arr,$status); echo status: $status [$result]br; -- The cgi program has been chmod'ed to 755 so it can run from a webpage and the cgi program runs fine when _not_ called from the PHP script. I get a status code of 155. Can someone please explain what this error code means! Thanks in advance Tony Frasketi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Having trouble with PHP exec function calling CGI program
Hi, Tony, I'm a middlebie, and I have the same problem. From the archives, I found the following suggestions from Richard Lynch: Does it work perfectly from the command line if you su to nobody (or whomever PHP runs as) before you execute it? Is it world executable? Does it access resources such as PGP key-rings that nobody can/cannot access? Are you sure you have the path correct? In my case, the answer is yes to all of the above (except for su'ing to nobody since I can't do that on this client's server). I've also discovered that it's usually a path/permission problem unless the server was built in 'safe mode' in which case, no script can be called. I added in `date`; to see if I could execute anything nothing happened, so I fear this. Now all I need to do is read up on suid in the PHP manual.Thankfully, this is just a tool for the client, and not something the world will see. Any other suggestions? Lara - Original Message - From: Tony Frasketi [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, August 13, 2001 6:08 AM Subject: [PHP] Having trouble with PHP exec function calling CGI program Hello list members I'm a newbie and having trouble with the EXEC function call from a PHP script. I've submitted this problem to the list last week but so far no response. And I still haven't figured it out. So here goes again. PHP EXEC function seems to work ok for executing shell commands like 'ls -al' etc. but when I execute the following PHP web page code... -- $basedir = '/mnt/web/xxx/myplace'; $cdir = $basedir . '/cgibin'; $cmd = cd $cdir;pwd;perl -w myscript.cgi; echo cmd: $cmdbr; $result = exec($cmd,$arr,$status); echo status: $status [$result]br; -- The cgi program has been chmod'ed to 755 so it can run from a webpage and the cgi program runs fine when _not_ called from the PHP script. I get a status code of 155. Can someone please explain what this error code means! Thanks in advance Tony Frasketi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Having trouble with PHP exec function calling CGI program
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 it could be that the webserver chroot()'s to some secure path, and thus your script cannot find `date`. perhaps all you have to do is to copy the binaries that you need into the safe directory (if you can first find out where the server is chroot()ing to) if you think that your server is doing this, read up on sandboxing, it might help you get a better picture of what's going on. -Original Message- From: Lara J. Fabans [mailto:[EMAIL PROTECTED]] Subject: Re: [PHP] Having trouble with PHP exec function calling CGI Hi, Tony, I added in `date`; to see if I could execute anything nothing happened, so I fear this. Now all I need to do is read up on suid in the PHP manual.Thankfully, this is just a tool for the client, and not something the world will see. Any other suggestions? Lara -BEGIN PGP SIGNATURE- Version: PGPfreeware 7.0.3 for non-commercial use http://www.pgp.com iQA/AwUBO3fnh8aXTGgZdrSUEQJRDACfdgGqeflDgZwq195fCsXnnDEUwNYAnjoR Z6MO47A8h5YdcECWy9ANrJdb =WoFm -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]