Skip site navigation (1) Skip section navigation (2)

Re: outputting everything from psql to a file

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Walker, Jed S" <Jed_Walker(at)cable(dot)comcast(dot)com>
Cc: "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: outputting everything from psql to a file
Date: 2005-03-25 19:45:01
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
"Walker, Jed S" <Jed_Walker(at)cable(dot)comcast(dot)com> writes:
> 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 don't think that there is any way to get error messages to go to a \o
file, but both \qecho output and query output do go there in a simple test.

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

Hm?  It can't go to the screen when you've redirected stderr like that.

Perhaps you are testing this on the same console where you started the
postmaster, and you didn't redirect the postmaster log somewhere?  If so
you're getting confused by the postmaster's log output.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Walker, Jed SDate: 2005-03-25 19:50:27
Subject: Re: outputting everything from psql to a file
Previous:From: Virgile BeddokDate: 2005-03-25 18:36:16
Subject: Function which gives back the nearest neighbours of a requested value

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group