0

I am new to programming. I am writing a bash script which runs 2 different programs. This is my script.

#!/bin/bash
./ngrok http 3005
node index2.js

The first command starts ngrok and the second one starts my local server. I noticed that they are executing one after the other. I want them to run parallel in 2 different terminal in linux. How do I do this?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
prem chopra
  • 107
  • 1
  • 3
  • 12
  • I tried this #!/bin/bash node index2.js & ./ngrok http 3005 && fg but got this error ---> ./start.sh: line 3: fg: no job control – prem chopra Dec 13 '17 at 19:41
  • Sounds like you either run the script with `sh scriptname` where `sh` is a shell without job control, or you have a Bash without job control. You can check that with `echo $-`; if the string contains `m`, you do have job control enabled. – Benjamin W. Dec 13 '17 at 20:19
  • There is no need for a well-behaving sserver to run in the foreground, and indeed it probably doesn't do that particularly well if it's designed to be a server. But if you want to run multiple terminals during developent, I added a duplicate which shows how to do that on X11. Similar arrangements (but probably with different command names) should work on other platforms, or with a different terminal in place of the traditional `xterm`. – tripleee Dec 14 '17 at 04:11

0 Answers0