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

From: kmh496 <kmh496(at)kornet(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: send psql output to file and setting pager=more
Date: 2006-05-20 10:19:12
Message-ID: 1148120352.29384.5.camel@var.sirfsup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I got angry and threw my computer out the window. So, you don't need to
reply anymore. Anyhow, let me tell you what happened.
> You still didn't tell us the OS you're using, btw ...
[postgres(at)www 2pg]$ cat /etc/redhat-release
Fedora Core release 4 (Stentz)
[postgres(at)www 2pg]$
[postgres(at)www 2pg]$
[postgres(at)www 2pg]$ psql --version
psql (PostgreSQL) 8.0.0beta3
contains support for command-line editing
[postgres(at)www 2pg]$
>
> > \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.
i can't get it to work here.

>
>
mydb1=# \pset pager less
Pager is used for long output.
mydb1=# \o
mydb1=# \oset
mydb1=# \set
VERSION = 'PostgreSQL 8.0.0beta3 on i686-pc-linux-gnu, compiled by GCC
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)'
AUTOCOMMIT = 'on'
VERBOSITY = 'default'
DBNAME = 'mydb1'
USER = 'postgres'
PORT = '5432'
ENCODING = 'UNICODE'
PROMPT1 = '%/%R%# '
PROMPT2 = '%/%R%# '
PROMPT3 = '>> '
HISTSIZE = '500'
LASTOID = '0'
mydb1=# \pset pager more
Pager usage is off.
mydb1=# \set
VERSION = 'PostgreSQL 8.0.0beta3 on i686-pc-linux-gnu, compiled by GCC
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)'
AUTOCOMMIT = 'on'
VERBOSITY = 'default'
DBNAME = 'mydb1'
USER = 'postgres'
PORT = '5432'
ENCODING = 'UNICODE'
PROMPT1 = '%/%R%# '
PROMPT2 = '%/%R%# '
PROMPT3 = '>> '
HISTSIZE = '500'
LASTOID = '0'
mydb1=# \pset pager more
Pager is used for long output.
mydb1=# \set
VERSION = 'PostgreSQL 8.0.0beta3 on i686-pc-linux-gnu, compiled by GCC
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)'
AUTOCOMMIT = 'on'
VERBOSITY = 'default'
DBNAME = 'mydb1'
USER = 'postgres'
PORT = '5432'
ENCODING = 'UNICODE'
PROMPT1 = '%/%R%# '
PROMPT2 = '%/%R%# '
PROMPT3 = '>> '
HISTSIZE = '500'
LASTOID = '0'
mydb1=# \pset pager
Pager usage is off.
mydb1=# \set
VERSION = 'PostgreSQL 8.0.0beta3 on i686-pc-linux-gnu, compiled by GCC
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)'
AUTOCOMMIT = 'on'
VERBOSITY = 'default'
DBNAME = 'mydb1'
USER = 'postgres'
PORT = '5432'
ENCODING = 'UNICODE'
PROMPT1 = '%/%R%# '
PROMPT2 = '%/%R%# '
PROMPT3 = '>> '
HISTSIZE = '500'
LASTOID = '0'
mydb1=# \pset pager always
Pager is always used.
mydb1=# \set
VERSION = 'PostgreSQL 8.0.0beta3 on i686-pc-linux-gnu, compiled by GCC
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)'
AUTOCOMMIT = 'on'
VERBOSITY = 'default'
DBNAME = 'mydb1'
USER = 'postgres'
PORT = '5432'
ENCODING = 'UNICODE'
PROMPT1 = '%/%R%# '
PROMPT2 = '%/%R%# '
PROMPT3 = '>> '
HISTSIZE = '500'
LASTOID = '0'
mydb1=# \pset pager less
Pager is used for long output.
mydb1=# \set
VERSION = 'PostgreSQL 8.0.0beta3 on i686-pc-linux-gnu, compiled by GCC
gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)'
AUTOCOMMIT = 'on'
VERBOSITY = 'default'
DBNAME = 'mydb1'
USER = 'postgres'
PORT = '5432'
ENCODING = 'UNICODE'
PROMPT1 = '%/%R%# '
PROMPT2 = '%/%R%# '
PROMPT3 = '>> '
HISTSIZE = '500'
LASTOID = '0'
mydb1=# \q
[postgres(at)www 2pg]$ echo $PAGER
more
[postgres(at)www 2pg]$ echo $SHELL
/bin/bash
[postgres(at)www 2pg]$ cat ~/.bashrc | grep PAGER
export PAGER=more

> > > > (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
>
>
--
my site <a href="http://www.myowndictionary.com">myowndictionary</a> was
made to help students of many languages learn them faster.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message sam karush 2006-05-20 10:47:43 PG on zeta 1.0
Previous Message Andrej Ricnik-Bay 2006-05-20 09:48:45 Re: send psql output to file and setting pager=more