简体   繁体   English

使用 PHP 中的参数调用 Perl:exec()、virtual() 等

[英]Calling Perl with parameters from PHP: exec(), virtual(), etc

I am trying to retrieve the output of a Perl cgi script that has parameters with a PHP page on Apache.我试图在 Apache 上检索具有 PHP 页面参数的 Perl cgi 脚本的输出。 If my PHP is如果我的 PHP 是

<? echo exec('../cgi-bin/test.cgi'); ?>

then I get the correct output (but I can't use the parameters).然后我得到正确的输出(但我不能使用参数)。 However, if my PHP is但是,如果我的 PHP 是

<? echo exec('../cgi-bin/test.cgi?m=1'); ?>

then I get no output.然后我没有输出。 When I use virtual()当我使用 virtual()

<? echo virtual('../cgi-bin/test.cgi?m=1'); ?>

I get a "Call to undefined function virtual()" error.我收到“调用未定义的函数 virtual()”错误。

My Perl script is getting the parameters with我的 Perl 脚本正在获取参数

my $co = new CGI;
my $mobile = $co->param('m') || 0;

I can't run the script from the command line because the shared hosting provider set the server that way.我无法从命令行运行脚本,因为共享主机提供商以这种方式设置服务器。

I don't know if this answer will help anyone else because it isn't technically calling the Perl script via CGI as I understand it, but greg_diesel let me to call the Perl script from PHP with multiple parameters: 我不知道此答案是否会对其他人有所帮助,因为据我所知,它在技术上不是通过CGI调用Perl脚本,但是greg_diesel让我从PHP使用多个参数调用Perl脚本:

exec('../cgi-bin/test.cgi "1" "2"');

and access the parameter in Perl with 并使用以下命令访问Perl中的参数

$ARGV[0];
$ARGV[1];

etc. instead of CGI. 等等,而不是CGI。

On thing to consider since it is a server side request is that the perl script submittal of parameters may initiate the script, but return of data may come from a different perl script.由于它是服务器端请求,因此需要考虑的是参数的 perl 脚本提交可能会启动脚本,但数据的返回可能来自不同的 perl 脚本。 a connector/link between the two might be some form of unique identifier.两者之间的连接器/链接可能是某种形式的唯一标识符。

'../cgi-bin/test.cgi' '../cgi-bin/test.cgi'

'../cgi-bin/run_test.cgi' '../cgi-bin/run_test.cgi'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM