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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -