note 28237 added to features.commandline
| From: | chris at chrisderose dot com | Date: | Mon, 06 Jan 2003 22:08:50 +0000 |
| Subject: | note 28237 added to features.commandline | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41759@lists.php.net to get a copy of this message | ||
I found that if I tried to use php in an already running cgi script, php would think it too was
running in cgi 'mode' instead of cli 'mode' . More specifically I was getting an
ambiguos "No input file specified" error from the php binary. The way I ended up fixing
this issue was to create the perl script below , and call this 'wrapper' script instead of
my own script directly. I'd imagine that deleting *all* of these environment variables is
unnecessary, but I don't have the time to figure out which one(s) specifically can stay. Has
anyone else found a *better* way of handling this condition? I'm running php 4.2.3 and
wondering if perhaps this bug has gone fixed in a later version.
#!/usr/bin/perl
# runphp_ascli_incgi.pl
# by Chris DeRose
$cmndPhp = '/home/cderose/cli_test.php';
delete $ENV{'CONTENT_LENGTH'};
delete $ENV{'CONTENT_TYPE'};
delete $ENV{'DOCUMENT_ROOT'};
delete $ENV{'GATEWAY_INTERFACE'};
delete $ENV{'HTTP_ACCEPT'};
delete $ENV{'HTTP_ACCEPT_ENCODING'};
delete $ENV{'HTTP_ACCEPT_LANGUAGE'};
delete $ENV{'HTTP_CACHE_CONTROL'};
delete $ENV{'HTTP_CONNECTION'};
delete $ENV{'HTTP_HOST'};
delete $ENV{'HTTP_PRAGMA'};
delete $ENV{'HTTP_REFERER'};
delete $ENV{'HTTP_USER_AGENT'};
delete $ENV{'HTTP_VIA'};
delete $ENV{'HTTP_X_FORWARDED_FOR'};
delete $ENV{'QUERY_STRING'};
delete $ENV{'REMOTE_ADDR'};
delete $ENV{'REMOTE_PORT'};
delete $ENV{'REQUEST_METHOD'};
delete $ENV{'REQUEST_URI'};
delete $ENV{'SCRIPT_FILENAME'};
delete $ENV{'SCRIPT_NAME'};
delete $ENV{'SERVER_ADDR'};
delete $ENV{'SERVER_ADMIN'};
delete $ENV{'SERVER_NAME'};
delete $ENV{'SERVER_PORT'};
delete $ENV{'SERVER_PROTOCOL'};
delete $ENV{'SERVER_SIGNATURE'};
delete $ENV{'SERVER_SOFTWARE'};
system ( $cmndPhp, @ARGV );
--
http://www.php.net/manual/en/features.commandline.php
http://master.php.net/manage/user-notes.php?action=edit+28237
http://master.php.net/manage/user-notes.php?action=delete+28237
http://master.php.net/manage/user-notes.php?action=reject+28237