简体   繁体   English

在 Windows 上使用多个命令行参数多次运行 node.js 脚本

[英]Run node.js script multiple times with multiple command line arguements on windows

I have a script named index.js which I need to run with multiple command line arguements, one at a time.我有一个名为index.js的脚本,我需要一次运行多个命令行参数。 Something like this:像这样的东西:

node index.js ABC
node index.js DEF
.
.
node index.js XYZ

So I have written all these arguements in a params.txt file, one on each line.所以我把所有这些论点都写在了一个 params.txt 文件中,每一行一个。 In this question, the solution for my problem is given, but it would not work on windows.这个问题中,给出了我的问题的解决方案,但它不适用于 Windows。 Can anyone tell me what script I need to run on windows to achieve what is being done in the linked question?谁能告诉我我需要在 Windows 上运行什么脚本来实现链接问题中正在执行的操作?

Thank You.谢谢你。

Try this尝试这个

In a .bat file:在 .bat 文件中:

FOR /F %%i in ( params.txt ) do (
    call node index.js %%i
)

Or just from the command line this'll probably work:或者只是从命令行这可能会起作用:

FOR /F %i in ( params.txt ) do call node index.js %i

Note that if you stick it in a batch file (eg runthemall.bat ) you need to double up the % signs.请注意,如果将其粘贴在批处理文件中(例如runthemall.bat ),则需要将%符号加倍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM