Re: send psql output to file and setting pager=more

From: "Andrej Ricnik-Bay" <andrej(dot)groups(at)gmail(dot)com>
To: kmh496 <kmh496(at)kornet(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: send psql output to file and setting pager=more
Date: 2006-05-20 09:48:45
Message-ID: b35603930605200248r4ef8c5c6p6601312f6e37247b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 5/20/06, kmh496 <kmh496(at)kornet(dot)net> wrote:

You still didn't tell us the OS you're using, btw ...

> I put export PAGER=more
> into my .bashrc and
> executed the command you stated, as well as
Did you check whether it's actually set before running
psql?

> \pset pager always
> \pset pager more
> but they don't stop after a page of input, so they seem to say they are
> doing the correct thing but really aren't.
All I can say is it works here (Postgres 8.1.3 on Slackware 10.2).
Without PAGER set in bash I get more, if I export PAGER=less
that's what PostgreSQL uses.

> > > (2) also, i want to have the results show up on the screen and be
> tee-ed
> > > to a file. Oracle can do this, i don't remember if it's "set server
> > > output on" or something like that?
>
> I learned the postgres equivalent is
> \o filename
> but this only directs STDOUT not STDERR
> but, i want to capture the error messages into a file so I can then edit
> that side by side with the other script which is generating the
> messages. Is it possible for \o to also capture output from both STDERR
> and STDOUT?
That's where the non-interactive version comes in... (at least
I have no idea how to redirect errors to a file from the interactive
one):
echo "select * from table;"|psql database 2>&1|tee what.txt

Cheers,
Andrej

--
Please don't top post, and don't use HTML e-Mail :} Make your quotes concise.

http://www.american.edu/econ/notes/htmlmail.htm

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message kmh496 2006-05-20 10:19:12 Re: send psql output to file and setting pager=more
Previous Message kmh496 2006-05-20 07:21:05 Re: send psql output to file and setting pager=more