php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28126 calling PHP CLI from other CGI ignores command-line
Submitted: 2004-04-23 17:04 UTC Modified: 2004-04-23 17:47 UTC
From: rasch at raschnet dot com Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 4.3.4 OS: Linux 2.4.25 (Debian unstable)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rasch at raschnet dot com
New email:
PHP Version: OS:

 

 [2004-04-23 17:04 UTC] rasch at raschnet dot com
Description:
------------
the php CGI binary detects the SERVER_SOFTWARE, SERVER_NAME, GATEWAY_INTERFACE, REQUEST_METHOD, and then ignores all command-line parameters.  The result is, that the below script combination prints out the entire perl script to the web server, since it reads it, and finds 0 php start/end tags.  I needed to do the below as we're working on a transition of some scripts from Perl to PHP.  As a workaround, i had to change the "system" line to "unset" all the environment variables listed above before launching the php script. 

Reproduce code:
---------------
-- perl script:
#!/usr/bin/perl

system("/path/to/script.php");


-- /path/to/script.php:
#!/usr/bin/php4 -q

print ("hello");


Expected result:
----------------
Expected the result to be "hi"

Actual result:
--------------
web server prints:
#!/usr/bin/perl

system("/path/to/script.php");



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-23 17:47 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

The CGI binary used the SERVER_SOFTWARE environment 
variable to determine if it is running on the command line 
or via a webserver. If this environment variable is set, 
then CGI binary thinks it is running from the server and 
does not parse command line arguments. 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 00:01:35 2025 UTC