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!
The problem is that after quote removal, the single quotes are no longer treated as syntax to escape the space, but literal characters as part of the string. Try
(I can’t find any information on
execlog, so I don’t know if the above will work.)