Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将文件从file()传递到Perl程序PHP_Perl_Localhost_Easyphp - Fatal编程技术网

将文件从file()传递到Perl程序PHP

将文件从file()传递到Perl程序PHP,perl,localhost,easyphp,Perl,Localhost,Easyphp,我有一个PHP代码,它通过file()方法存储url的内容,如 $contents=file("http://www.rcsb.org/pdb/files/2AID.pdb"); 我需要通过shell_exec()方法将这些$contents传递给perl程序,如下所示 $result=shell_exec("perl_prog.pl $contents"); 我的问题是如何将$contents传递给Perl程序。我试着跟在后面 @file=<@ARGV>; @file=;

我有一个PHP代码,它通过file()方法存储url的内容,如

$contents=file("http://www.rcsb.org/pdb/files/2AID.pdb"); 
我需要通过shell_exec()方法将这些$contents传递给perl程序,如下所示

$result=shell_exec("perl_prog.pl $contents");
我的问题是如何将$contents传递给Perl程序。我试着跟在后面

@file=<@ARGV>;
@file=;
但它不起作用。请帮帮我。

shell_exec()代码完全容易受到shell注入的攻击-您相信远程服务不会包括以下内容:

; rm -rf /
另外,
file()
以数组的形式返回文件内容-不能直接通过命令行传递数组。只有字符串

较为安全的版本是:

$contents = file_get_contents('http://etc....');
$safe_contents = escapeshellarg($contents);
$result = shell_exec('perl_prog.pl $safe_contents');
在Perl方面,您可以使用

my ($contents) = @ARGV;
根据文档,已经添加了报价。固定的。