Windows 批处理脚本输入参数
假设您有一个脚本,它接受几个命令行参数并将其结果转储到 stdout
。
手动调用此脚本将如下所示:
perl foo.pl arg1 arg2 arg3
在不更改相关脚本的情况下,Windows 下是否可以获取文件的内容(例如,input.txt
是一个带有 < code>arg{1,3} 每行由空格分隔)并执行如下操作:
foreach line in input.txt
perl foo.pl current_line >> output.txt
现在,我只有另一个 Perl 脚本可以执行此操作,但想知道这是否可能。
Suppose you have a script that takes a couple of command-line arguments and dumps its results to stdout
.
Manually invoking this script will look like this:
perl foo.pl arg1 arg2 arg3
Without changing the script in question, is it possible under Windows to take the contents of a file (e.g., input.txt
is a multi-line text file with arg{1,3}
delimited by a whitespace on each line) and execute something like this:
foreach line in input.txt
perl foo.pl current_line >> output.txt
Right now, I just have another Perl script that does this, but was wondering if this was possible anyway.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会说是的。
我在 Google 上搜索了
windows 批处理循环
并得到了此页面:http:// /www.robvanderwoude.com/for.php。我在网站上查找并找到了此页面:http://www.robvanderwoude.com/ntfor。 php#FOR_F
所以看起来代码会是这样的......
I'm gonna say yes.
I searched the web with Google for
windows batch loops
and got this page: http://www.robvanderwoude.com/for.php.I dug around on the site and found this page: http://www.robvanderwoude.com/ntfor.php#FOR_F
So it looks like the code would be something like...