0

My shellscript looks like

for i in {1..5}
    do
        echo "Welcome $i times"
        exec node nodefile.js
done

and the nodefile.js looks like

console.log 'running nodefile'

When I call the ./shellscript.sh there will only be displayed "Welcome x times" and "running nodefile" once.

Whats missing there? Is there anything that I have to return in nodefile or something else?

2 Answers 2

1

Try this

for i in {1..5}
do
   echo "Welcome $i times"
   node process.js
done
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. Sometimes it could be so easy :)
0

As an alternative you might try using the 'sha-bang' method.

Put this in your nodefile.js:

#!/the/location/of/your/node
console.log("running nodefile");

Then make the nodefile.js executable by doing:

chmod +x nodefile.js

Now your shell script can look something like this:

for i in {1..5}
do
   echo "Welcome $i times"
   /location/of/nodefile.js
done

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.