Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer
    
Stupid mistake from my side, thanks! –  Izac Apr 6 '12 at 16:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.