Being on Ubuntu Server I am trying to write an automation script.

Here is what I have:


while [ "$1" != "" ]; do
    case $1 in
        -p | --port )           shift
        -d | --domain )         shift
        -l | --location )       shift
        * )                     exit 1

echo "Parsing finished. List of domain is: "
for val in "${DOMAIN[@]}"; do
    echo " - $val"

echo "Generating -d domain list..."
for val in "${DOMAIN[@]}"; do
    domains="$domains -d $val"

echo "-d list is: $domains"

echo "Port is: $PORT."

echo "Location to save is: $PATH"

certbot certonly --standalone --standalone-supported-challenges http-01 --http-01-port $PORT $domains --cert-path $PATH

When ran with just two parameters, it works correctly. When I specify the third parameter -l or --location, it gives:

cert-ggm.sh: line 35: certbot: command not found

I tried to rename the -l parameter to capital P, got the same result. The test echoes return correct value parse. What's the deal with the location parameter casting certbot command uncallable? Thank you in advance.

  • 3
    That's the result of using PATH for your user-defined variable - it's stomping on the system's executable search PATH – steeldriver Feb 7 '17 at 15:49
  • Change PATH to something else. for example 'location' or 'userpath' and see if this happens again – Mostafa Ahangarha Feb 7 '17 at 15:53
  • @steeldriver thanks, that was it. Please paste your comment as an answer and I will accept it. – Maxim V. Pavlov Feb 9 '17 at 9:30

Browse other questions tagged or ask your own question.