outputting everything from psql to a file

From: "Walker, Jed S" <Jed_Walker(at)cable(dot)comcast(dot)com>
To: "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>
Subject: outputting everything from psql to a file
Date: 2005-03-25 17:39:02
Message-ID: 41669DC6FE3B80449A33A4DD46DB370A09E7E8BB@entcoexch15.broadband.att.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello again,

I'm stuck on another issue. I need to specify in a sql script I'm calling
from psql that I want everything to go to an output file. So, I have in my
sql file:

\o example1.lst
\qecho This is an example
select current_user;
select hope from none;

The problem I have is that the output of the first query and the error from
the second query go to standard out/error (it appears) and not to the output
file. I need everything to go to the output file. I can't find anything in
the psql documentation on how to do this. Is there a way? Or do I have to do
something like:

{
psql -U user <<EOF
\echo This is an example
select current_user;
select hope from none;
EOF
} > example1.lst 2>&1

which gives me what I want except that the error goes to both the output
file and the screen.

Thanks again,

Jed S. Walker

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Virgile Beddok 2005-03-25 18:36:16 Function which gives back the nearest neighbours of a requested value
Previous Message Michelle Konzack 2005-03-25 15:48:50 Re: install pgaccess under windows xp