php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18537 calling php from perl only gives "No input file specified."
Submitted: 2002-07-24 08:03 UTC Modified: 2002-08-02 05:09 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: s dot lemke at infoworxx dot de Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.2.2 OS: Suse Linux 7.3
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: s dot lemke at infoworxx dot de
New email:
PHP Version: OS:

 

 [2002-07-24 08:03 UTC] s dot lemke at infoworxx dot de
Hello,

I have a problem calling PHP from Perl and did not find anything about this problem in the web nor in the bug-database. 

I tried this:
---
open(OUTPUTFILE, "| /usr/local/bin/php");
select(OUTPUTFILE);
    --producing my output with perl--
close(OUTPUTFILE);
---

With other Unix-Programs like "cat" everything works fine. Sendmail also uses this syntax for getting input.

I have provided a small sample with 4 cases; case 2 is the one, wich does not work.

I hope, you can help me.

Regards, 
Sebastian

---- sample.pl ----
#!/usr/bin/perl -w

#	Test-Script
######################

use strict;
use warnings;

my $isCGI++ if defined($ENV{'GATEWAY_INTERFACE'}) && $ENV{'GATEWAY_INTERFACE'}=~/CGI/;

	if ($isCGI) {
		use CGI qw(:standard);
		my $cgihandler = new CGI;
		use CGI::Carp qw(fatalsToBrowser);
		
		### case 1 : only printing test and <? phpinfo(); ?>
#		print "Content-type: text/html\n\n";
#		print "test\n";
#		print "<? phpinfo(); ?>\n";
#		exit;

		### case 2: PHP after PERL try
		# Error Message returning: "No input file specified."
		my $acthandle=select();				
			open(OUTPUTFILE, "| /usr/local/bin/php");
			select(OUTPUTFILE);
				print "Content-type: text/html\n\n";
				print "test\n";
				print "<? phpinfo(); ?>\n";
			close(OUTPUTFILE);
		select($acthandle);
		exit;

		### case 3: same routine like calling php, 
		### but calling unix-command "cat"
		# works fine !!!
#		my $acthandle=select();				
#			open(OUTPUTFILE, "| /bin/cat");
#			select(OUTPUTFILE);
#				print "Content-type: text/html\n\n";
#				print "test\n";
#				print "<? phpinfo(); ?>\n";
#			close(OUTPUTFILE);
#		select($acthandle);
#		exit;

		### case 4: calling php via "system" command
		### works, but not optimal...
#		my $acthandle=select();				
#			open(OUTPUTFILE, "> /tmp/cms.temp");
#			select(OUTPUTFILE);
#				print "Content-type: text/html\n\n";
#				print "test\n";
#				print "<? phpinfo(); ?>\n";
#			close(OUTPUTFILE);
#		select($acthandle);
#		exec '/usr/local/bin/php', '/tmp/cms.temp';
#		exit;
	} else {
		print "Demo using CGI.\n";
		exit;
	}

--- end ---


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-24 09:33 UTC] edink@php.net
That could be because php detects cgi env. variables present and tries to act accordingly. Could you try compiling php with --enable-cli and copy sapi/cli/php from you php build tree into /usr/local/bin/php?

You can get more information about the differences between cgi and cli versions of php on http://www.php.net/manual/en/features.commandline.php
 [2002-07-25 03:14 UTC] s dot lemke at infoworxx dot de
Hi,

at first of all, thanks for your fast answer. I have tried it yesterday - calling php and processing the output of my perl script works when I am using the cli-feature - but as described in the manual the "Header" functions does not work. 
Therefore I need an cgi-version which is capable of being started in the described way. 

Is this possible or are there any other possiblities to get this running ?

Regards,
Sebastian
 [2002-07-25 04:29 UTC] derick@php.net
You can alsways echo the headers out yourself:
<?php
echo "Content-type: text/html\r\n";
?>

Derick
 [2002-07-25 16:31 UTC] s dot lemke at infoworxx dot de
Hi

Can I detect inside my php script if the php binary is running in cli mode ? And can I redefine the "Header" command ?

regards,
Sebastian
 [2002-07-25 20:16 UTC] sniper@php.net
This works fine fore me with PHP 4.3.0-dev and PHP 4.2.2:

#!/usr/bin/perl

open(OUTPUTFILE, "| /usr/local/bin/php");
select(OUTPUTFILE);
print "Content-type: text/html\n\n";
print "test\n";
print "<?php phpinfo(); ?>\n";
close(OUTPUTFILE);
exit;

---


 [2002-08-02 04:59 UTC] s dot lemke at infoworxx dot de
Hello,

if hvried it this way... ButInd teoutput-buffering function of php - my application is very complex and for some reasons I cannot detect at the beginning of the script if a redirect (with the Header/Location command) is necessary.

Regards,
Sebastian
 [2002-08-02 05:09 UTC] edink@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 09:00:02 2026 UTC