0

I want to run a bash script to access two terminal tabs, each run cd "folder", then "npm run start", as below:

 #!/bin/bash
    sudo mysql -u root -h localhost 
    PATH=/var/lib/cloud9/autorun/loginbrillo
    tmux new-session -d -s session1 "cd $PATH/backend && npm run start" &
    tmux new-session -d -s sessionn1 "cd $PATH/frontend && npm run start" &
    chromium-browser  http://192.168.7.2:4001/

When I run it, I get :

tmux: command not found
npm: command not found
chromium-browser: command not found

How to fix it please ?

1
  • Don't use all-caps for your shell script variables - they are (informally) reserved for system environment variables. In this case, you've overwritten your shell's executable search path PATH - which is why no programs are being found. Just change the variable PATH to something else like cloudpath Jul 6, 2018 at 22:14

1 Answer 1

-1

The PATH variable is used to find all commands your script will use but rather than adding new directories to it you have overwritten it with a single directory, replace your second line with the following:

PATH=$PATH:/var/lib/cloud9/autorun/loginbrillo

PATH is a colon seperated list, this will get the current value of PATH, append a colon to it and add your directory to it

2
  • The OP appears to be using PATH as a working directory variable, not an executable search path Jul 6, 2018 at 21:54
  • Great ! I get just : chromium-browser: command not found Jul 6, 2018 at 22:21

Not the answer you're looking for? Browse other questions tagged .