0

I have a small shell script thats gets triggerd by another script via ssh.

#!/bin/bash

if [ -z $1 ]
    then
echo "Missing DB Name!"
exit 1
    else 
    PROJECT=$1
fi

createdb -U postgres -T mytemplate -O myuser $PROJECT_dev

The problem is that the createdb statement doesent sees the $PROJECT variable. It's always empty when the script gets called.

I have no idea why.

0

Use curly brackets to delimit your actual variable:

createdb -U postgres -T mytemplate -O myuser ${PROJECT}_dev

otherwise, bash thinks the whole "PROJECT_dev" is your variable.

0

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.