I get an error while executing the following psql statement inside a bash script:
execlog "psql -h $HOST -p $PORT -U $USER -d $DB -q -c 'CREATE EXTENSION hstore;'"
The raised error is:
ERROR: unterminated quoted string at or near "'CREATE" LINE 1: 'CREATE ^
Thus, the single terminating quote is not recognize as it should be. When using escaped double quotes instead single quotes (...\"CREATE EXTENSION hstore;\") I get the same error. When executing the command directly from the command line, everything works fine.
Does someone know what's going wrong?
To give some additional info:
OS: Ubuntu 11.10, Postgresql Verion: 9.1
Thanks in advance, Richard
Solved: The execlog function produces the error. Now I am calling
log "exec psql -h $HOST -p $PORT -U $USER -d $DB -q -c 'CREATE EXTENSION hstore;'"
which works fine!
Thanks for your help!
set -x, this will write to stderr the command being executed. then you can see what gets passed to psql.