postgresql - insert bash-variables in psql-command -
i'm going crazy while trying insert bash-variables in psql commands connection paramters variables in command itself. following example works properly:
psql -u postgres -h localhost -p 5432 -c "create database testdb encoding='utf8' owner=postgres tablespace=pg_default template=template_postgis connection limit=-1;"
now i'm trying exchange each parameter through variable, held in special config-file.
non-working example:
dbserver=localhost dbport=5432 dbowner=postgres dbname=testdb dbtemplate=template_postgis dbtablespace=pg_default psql -u '$dbowner' -h '$dbserver' -p '$dbport' -c "create database '$dbname' encoding='utf8' owner='§dbowner' tablespace='$dbtablespace' template='$dbtemplate' connection limit=-1;"
i've tried several quotings, backquotes , escape-slashes smhow still won't work. in advance, knutella
this works... of quotes not needed:
psql -u $dbowner -h $dbserver -p $dbport -c "create database $dbname encoding='utf8' owner=$dbowner tablespace=$dbtablespace template=$dbtemplate connection limit=-1;"
Comments
Post a Comment