Re: exec from process (deamon) without shell

From: Date: Thu, 01 Mar 2007 23:12:50 +0000
Subject: Re: exec from process (deamon) without shell
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-249676@lists.php.net to get a copy of this message
Quoting Roman Neuhauser <neuhauser@sigpipe.cz>:
# lists@dwsasia.com / 2007-03-01 18:28:35 +0200:
#/thepathtophp <?php exec("ls -lrt", $stdout, $exitcode); if($exitcode!=0) {
            echo "Command ls -lrt could not be executed correctly.  Exit code: $exitcode\n";
} else {
            echo "Result:\n";
            foreach($stdout AS $line) {
                        echo $line."\n";
            }
} ?> This code give the exit code -1 that is equal to that "ls -lrt" could not be executed.
Does the daemon run chrooted somewhere? What does $PATH contain? What happens if you use /bin/ls? -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991
Becuase this only is having problems when executing from the deamon I added: exec("php -i", $stdout, $exitcode); And then put it into a logfile. Is there anything here that makes $exitcode for all commands executed -1, but they still seams to be functional as $stdout is as expected: 2007-03-02 00:00:54 Environment 2007-03-02 00:00:54 2007-03-02 00:00:54 Variable => Value 2007-03-02 00:00:54 TERM => xterm 2007-03-02 00:00:54 PATH => /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/bin 2007-03-02 00:00:54 _ => /usr/bin/php 2007-03-02 00:00:54 PWD => /var/www/util 2007-03-02 00:00:54 LANG => C 2007-03-02 00:00:54 SHLVL => 6 2007-03-02 00:00:54 2007-03-02 00:00:54 PHP Variables 2007-03-02 00:00:54 2007-03-02 00:00:54 Variable => Value 2007-03-02 00:00:54 _SERVER["TERM"] => xterm 2007-03-02 00:00:54 _SERVER["PATH"] => /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/bin 2007-03-02 00:00:54 _SERVER["_"] => /usr/bin/php 2007-03-02 00:00:54 _SERVER["PWD"] => /var/www/util 2007-03-02 00:00:54 _SERVER["LANG"] => C 2007-03-02 00:00:54 _SERVER["SHLVL"] => 6 2007-03-02 00:00:54 _SERVER["PHP_SELF"] => 2007-03-02 00:00:54 _SERVER["SCRIPT_NAME"] => 2007-03-02 00:00:54 _SERVER["SCRIPT_FILENAME"] => 2007-03-02 00:00:54 _SERVER["PATH_TRANSLATED"] => 2007-03-02 00:00:54 _SERVER["DOCUMENT_ROOT"] => 2007-03-02 00:00:54 _SERVER["REQUEST_TIME"] => 1172786454 2007-03-02 00:00:54 _SERVER["argv"] => Array 2007-03-02 00:00:54 ( 2007-03-02 00:00:54 ) 2007-03-02 00:00:54 2007-03-02 00:00:54 _SERVER["argc"] => 0 2007-03-02 00:00:54 _ENV["TERM"] => xterm 2007-03-02 00:00:54 _ENV["PATH"] => /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/bin 2007-03-02 00:00:54 _ENV["_"] => /usr/bin/php 2007-03-02 00:00:54 _ENV["PWD"] => /var/www/util 2007-03-02 00:00:54 _ENV["LANG"] => C 2007-03-02 00:00:54 _ENV["SHLVL"] => 6

« previous php.general (#249676) next »