note 28237 deleted from features.commandline by alindeman
| From: | alindeman@php.net | Date: | Sat, 03 May 2003 13:24:05 +0000 |
| Subject: | note 28237 deleted from features.commandline by alindeman | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-47424@lists.php.net to get a copy of this message | ||
[Ed note: CLI SAPI doesn't have this problem and it's recommended for command line scripts
as of PHP 4.3.0]
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 );