1

I am working in the following scripto to activate the front end and back end of my project as follows:

#!/bin/bash
cd /Users/perf-fe/
source my_project_34/bin/activate
npm start 
&&
cd /Users/perf-be/
export FLASK_APP=router.py
flask run

However it is not working, It is showing just the first part:

#!/bin/bash
cd /Users/perf-fe/
source my_project_34/bin/activate
npm start 
&&

Since the first process occupies the entire terminal, I would like to appreciate suggestions

  • What do you think the line with && will do and what do you want it to do? – Jesse_b May 25 '18 at 19:04
  • @Jesse_b I am using that in order to continue with the following commands – neo33 May 25 '18 at 19:06
  • It should be giving a syntax error. That is not a valid use of && – Jesse_b May 25 '18 at 19:07
  • @neo33 you want to make the: npm start run in background right? – vfbsilva May 25 '18 at 19:13
  • @vfbsilva yes I want that, something to return the control of the terminal – neo33 May 25 '18 at 19:13
6

You probably want to start the first process in its own job, and then execute the second:

cd /Users/perf-fe/
source my_project_34/bin/activate
npm start &
cd /Users/perf-be/
export FLASK_APP=router.py
flask run

The & tells the shell to run the previous command as a background job, and to continue with the next command even though the prior is still running.

This is distinct from &&, which is a syntax error as you present it. Its use is between two commands, to execute the second if and only if the exit code of the first is zero.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.