Command not found on bash script

8,675

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

Share:
8,675

Related videos on Youtube

Ichrak Mansour
Author by

Ichrak Mansour

I am Full stack engineer with more than 4 years of experience and solid experience in Fullstack and Mobile development. I like to build websites and mobile applications that can have a large satisfied user-base, delight and inspire people.

Updated on September 18, 2022

Comments

  • Ichrak Mansour
    Ichrak Mansour over 1 year

    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 ?

    • steeldriver
      steeldriver almost 6 years
      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
  • steeldriver
    steeldriver almost 6 years
    The OP appears to be using PATH as a working directory variable, not an executable search path
  • Ichrak Mansour
    Ichrak Mansour almost 6 years
    Great ! I get just : chromium-browser: command not found