note 38905 added to function.shell-exec

From: Date: Sun, 11 Jan 2004 06:13:37 +0000
Subject: note 38905 added to function.shell-exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-63302@lists.php.net to get a copy of this message
I have PHP (CGI) and Apache. I also shell_exec() shell scripts which use PHP CLI. This combination destroys the string value returned from the call. I get binary garbage. Shell scripts that start with #!/usr/bin/bash return their output properly. A solution is to force a clean environment. PHP CLI no longer had the CGI environment variables to choke on. <?php // Binary garbage. $ExhibitA = shell_exec('/home/www/myscript'); // Perfect. $ExhibitB = shell_exec('env -i /home/www/myscript'); ?> -- start /home/www/myscript #!/usr/local/bin/phpcli <?php echo("Output.\n"); ?> -- end /home/www/myscript ---- Manual Page -- http://www.php.net/manual/en/function.shell-exec.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38905 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38905&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38905&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#63302) next »