pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedpsql in the command line
3+ messages / 3 participants
[nested] [flat]
* psql in the command line
@ 2006-01-25 15:57 Aniko.Badzong@swisscom.com
2006-01-25 16:05 ` Re: psql in the command line Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 1 reply; 3+ messages in thread
From: Aniko.Badzong@swisscom.com @ 2006-01-25 15:57 UTC (permalink / raw)
To: pgsql-sql
Hi
I need some help regarding psql syntax.
I would like to copy text files into the database from the command line
in a script.
I have found already how can I do it as user postrgres:
test:/opt/pgsql# echo "copy test from '/data/log/bla';" | psql logdb
COPY
But when I try to execute it as root user I get the following error:
[est/data/log] su - postgres -c "echo 'copy test from /data/log/bla;'|
psql logdb"
ERROR: syntax error at or near "/" at character 16
LINE 1: copy test from /data/log/bla;
I have already tried with all kind of double and single quotes but it
does not work.
Anybody has an idea how can I make it run?
Thanks and regards
Aniko
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: psql in the command line
2006-01-25 15:57 psql in the command line Aniko.Badzong@swisscom.com
@ 2006-01-25 16:05 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
0 siblings, 0 replies; 3+ messages in thread
From: Alvaro Herrera @ 2006-01-25 16:05 UTC (permalink / raw)
To: Aniko.Badzong@swisscom.com; +Cc: pgsql-sql
Aniko.Badzong@swisscom.com wrote:
> test:/opt/pgsql# echo "copy test from '/data/log/bla';" | psql logdb
> COPY
>
> But when I try to execute it as root user I get the following error:
>
> [est/data/log] su - postgres -c "echo 'copy test from /data/log/bla;'|
> psql logdb"
> ERROR: syntax error at or near "/" at character 16
> LINE 1: copy test from /data/log/bla;
This is clearly not the same line. The quotes are not in the same
position as in the line above.
su - postgres -c "psql logdb -c 'copy test from \'data/log/bla\''"
--
Alvaro Herrera http://www.advogato.org/person/alvherre
"Es filósofo el que disfruta con los enigmas" (G. Coli)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: psql in the command line
@ 2006-01-25 17:43 Owen Jacobson <ojacobson@osl.com>
0 siblings, 0 replies; 3+ messages in thread
From: Owen Jacobson @ 2006-01-25 17:43 UTC (permalink / raw)
To: pgsql-sql
Alvaro Herrera wrote:
> Aniko.Badzong@swisscom.com wrote:
>
> > test:/opt/pgsql# echo "copy test from '/data/log/bla';" | psql logdb
> > COPY
> >
> > But when I try to execute it as root user I get the following error:
> >
> > [est/data/log] su - postgres -c "echo 'copy test from
> /data/log/bla;'|
> > psql logdb"
> > ERROR: syntax error at or near "/" at character 16
> > LINE 1: copy test from /data/log/bla;
>
> This is clearly not the same line. The quotes are not in the same
> position as in the line above.
>
> su - postgres -c "psql logdb -c 'copy test from \'data/log/bla\''"
Or, preferably:
$ echo "copy test from '/data/log/bla';" | sudo -u postgres psql logdb
HTH,
Owen
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-01-25 17:43 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-25 15:57 psql in the command line Aniko.Badzong@swisscom.com
2006-01-25 16:05 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
2006-01-25 17:43 Re: psql in the command line Owen Jacobson <ojacobson@osl.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox