Обсуждение:
Hi
I have tried it yesterday to escaoe the double qutoes and I get the error:
[test] su - postgres -c "echo \"copy test from '/data/log/bla';"\" | psql logdb"
Unmatched ".
somehow does not want to work.
RE: [SQL] psql in the command line
from: Russell Simpkins [russellsimpkins@hotmail.com]
if in fact this works: echo "copy test from '/data/log/bla';" | psql logdb
then you probably want to write it like this:
su - postgres -c "echo \"copy test from '/data/log/bla';\"|>psql logdb"
so that you escape the double quotes.
Aniko.Badzong@swisscom.com wrote: > Hi > > I have tried it yesterday to escaoe the double qutoes and I get the > error: > > [test] su - postgres -c "echo \"copy test from '/data/log/bla';"\" | > psql logdb" > Unmatched ". You still don't fix it? I remembered yesterday that the shell doesn't want escaped quotes inside a quoted argument, so you must quit the quoted environment and put an escaped quote, something like su - postgres -c "echo "\""copy test from '/data/log/bla';"\"" | pgsql logdb" The echo-pipe is still overkill, you can do it using -c as I showed yesterday by applying the same "trick". -- Alvaro Herrera Valdivia, Chile ICBM: S 39º 49' 17.7", W 73º 14' 26.8" "Es filósofo el que disfruta con los enigmas" (G. Coli)
<Aniko.Badzong@swisscom.com> writes: > [test] su - postgres -c "echo \"copy test from '/data/log/bla';"\" | > psql logdb" > Unmatched ". > somehow does not want to work. You've got too many quote marks. su - postgres -c "echo \"copy test from '/data/log/bla';\" | psql logdb" regards, tom lane