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