Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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
如何用perl从网站执行一个perl脚本?_Perl_File_Cmd_Cgi - Fatal编程技术网

如何用perl从网站执行一个perl脚本?

如何用perl从网站执行一个perl脚本?,perl,file,cmd,cgi,Perl,File,Cmd,Cgi,我正在尝试运行perl脚本,用perl做一些事情并从web浏览器页面创建文件。我正在使用Windows7 资料来源: use CGI; use warnings; use strict; print "Content-type:text/html; charset=utf-8\r\n\r\n"; print "<a href='./#'>START</a>"; system("C:\Perl\bin\perl C:\xampp\htdocs\xampp\bc\crea

我正在尝试运行perl脚本,用perl做一些事情并从web浏览器页面创建文件。我正在使用Windows7

资料来源:

use CGI;
use warnings;
use strict;

print "Content-type:text/html; charset=utf-8\r\n\r\n";

print "<a href='./#'>START</a>";
system("C:\Perl\bin\perl C:\xampp\htdocs\xampp\bc\create_yaml.pl");
create.pl的源代码:

open(INFO,">aaaaaaa.txt");
print INFO "voda";
close INFO;

我认为您的问题是Windows使用\作为路径名,但当您将其置于引号中时,需要将其转义,因为它是一个特殊字符。你带着\:

system("C:\\Perl\\bin\\perl C:\\xampp\\htdocs\\xampp\\bc\\create_yaml.pl");
此外,如果环境路径变量设置正确,则可以执行以下操作:

system("perl C:\\xampp\\htdocs\\xampp\\bc\\create_yaml.pl");
或者正如amon指出的,您可以使用前斜杠:

system("C:/Perl/bin/perl C:/xampp/htdocs/xampp/bc/create_yaml.pl");

更好的方法是:使用前斜杠。同样有效,阅读也更容易。另外,将命令分成一个字符串列表(
system$executable,@args
)通常更可取;严格使用;使用警告;打印“内容类型:text/html;字符集=utf-8\n\n”;系统(“C:\\Perl\\bin\\Perl C:\\xampp\\htdocs\\xampp\\vyber\\bc\\test\\create.pl”)create.pl source
open(INFO,“>aaaaaaa.txt”);打印信息“voda”;关闭信息但它不会创建任何文件如果您使用的是64位Perl,那么您的路径是错误的。很可能是
“C:\\Perl64\\bin\\perl
。您的一条或两条路径都不正确。其他任何路径都没有意义。
system("C:/Perl/bin/perl C:/xampp/htdocs/xampp/bc/create_yaml.pl");