Xiphias
Xiphias

Reputation: 4716

Why is my command not found but works in the command line?

This is a part of my script:

read -p "[q] What is the meteor project's location? "
PATH=$REPLY
cd $PATH
cd src
echo $(pwd)
mrt bundle bundle.tar.gz

It prints the correct working directory. Entering mrt bundle bundle.tar.gz in the console works. Executing my script, I get meteor_bundle.sh: line 9: bash: command not found. What could be the reason?

Upvotes: 2

Views: 275

Answers (2)

damienfrancois
damienfrancois

Reputation: 59120

You choose the variable name poorly: PATHhas a special meaning in Bash: it is used to indicate Bash where to look for executable programs. Choose another name (preferably lowercase, see @Gordon's comment) and it should be fine.

Upvotes: 4

Radu Rădeanu
Radu Rădeanu

Reputation: 2722

You should use the full path for mrt because you changed the value of the PATH. Or choose another name for the variable from the second line.

See the following post to understand exactly what is the purpose of the PATH environment variable:

Upvotes: 3

Related Questions