Sergei V Kim
Sergei V Kim

Reputation: 205

How to run node.js app multiple times with different arguments in command line

I need to start node.js app multiple times (200-300 times) with different arguments. Like so:

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

What is the best approach to achieve that?

Upvotes: 0

Views: 1606

Answers (1)

Yongfeng
Yongfeng

Reputation: 686

  1. put all your arguments line by line in params.txt :

    ABC

    DEF

    GHI

    ...

    XYZ

  2. RUN cat params.txt | while read -r param; do node index.js $param; done

The script above read the file line by line and pass it to your js script

Upvotes: 2

Related Questions