Bug #18537 Updated: calling php from perl only gives "No input file specified."
| From: | edink@php.net | Date: | Wed, 24 Jul 2002 13:33:50 +0000 |
| Subject: | Bug #18537 Updated: calling php from perl only gives "No input file specified." | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-15044@lists.php.net to get a copy of this message | ||
ID: 18537
Updated by: edink@php.net
Reported By: s.lemke@infoworxx.de
-Status: Open
+Status: Feedback
Bug Type: *General Issues
Operating System: Suse Linux 7.3
PHP Version: 4.2.2
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2002-07-24 08:03:04] s.lemke@infoworxx.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 ---
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18537&edit=1