Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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
Windows批处理脚本馈送参数_Windows_Batch File_Command Line Arguments_File Get Contents - Fatal编程技术网

Windows批处理脚本馈送参数

Windows批处理脚本馈送参数,windows,batch-file,command-line-arguments,file-get-contents,Windows,Batch File,Command Line Arguments,File Get Contents,假设您有一个脚本,它接受两个命令行参数并将其结果转储到stdout 手动调用此脚本将如下所示: perl foo.pl arg1 arg2 arg3 foreach line in input.txt perl foo.pl current_line >> output.txt 在不更改相关脚本的情况下,是否可以在Windows下获取文件的内容(例如,input.txt是一个多行文本文件,每行上用空格分隔arg{1,3}),并执行以下操作: perl foo.pl arg1

假设您有一个脚本,它接受两个命令行参数并将其结果转储到
stdout

手动调用此脚本将如下所示:

perl foo.pl arg1 arg2 arg3
foreach line in input.txt
  perl foo.pl current_line >> output.txt
在不更改相关脚本的情况下,是否可以在Windows下获取文件的内容(例如,
input.txt
是一个多行文本文件,每行上用空格分隔
arg{1,3}
),并执行以下操作:

perl foo.pl arg1 arg2 arg3
foreach line in input.txt
  perl foo.pl current_line >> output.txt
现在,我有另一个Perl脚本可以实现这一点,但我想知道这是否可行。

我会说是的

我在网上用谷歌搜索了
windows批处理循环
,得到了这个页面:

我在网站上四处搜索,发现了以下页面:

所以代码看起来像是

FOR /F %%variable IN (input.txt) DO perl foo.pl %%variable >> output.txt

语法有点不同。在(input.txt)中/F%%a的批处理文件中,执行perl foo.pl%%a>>output.txt。在(input.txt)中输入/F%a的命令提示符下,执行perl foo.pl%a>>output.txt