Обсуждение: Capturing all output from psql into a file

Поиск
Список
Период
Сортировка

Capturing all output from psql into a file

От
"Huy Do"
Дата:
Hi,

I am doing this mass table creation (approx 600 tables) and then
mass dump of records into these tables (~900megs of flat files).

All the table creation and record copy is being done from a file
using \i sqlscript.txt.

How can I capture all the output which comes out from psql. I need
all the errors and not just the query result.

I have tried to use \o file.txt and \g file.txt but they only
seem to output the query result.

Many thanks.

Huy

RE: Capturing all output from psql into a file

От
"Tamsin"
Дата:
I use this:

psql dbname -c "\i sqlscript.txt" &> file.txt

(enter at shell prompt rather than going into psql first)

Hope this helps,
Tamsin


> -----Original Message-----
> From: pgsql-novice-owner@postgresql.org
> [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of Huy Do
> Sent: 20 December 2000 05:37
> To: pgsql-novice@postgresql.org
> Subject: [NOVICE] Capturing all output from psql into a file
>
>
> Hi,
>
> I am doing this mass table creation (approx 600 tables) and then
> mass dump of records into these tables (~900megs of flat files).
>
> All the table creation and record copy is being done from a file
> using \i sqlscript.txt.
>
> How can I capture all the output which comes out from psql. I need
> all the errors and not just the query result.
>
> I have tried to use \o file.txt and \g file.txt but they only
> seem to output the query result.
>
> Many thanks.
>
> Huy
>

RE: Capturing all output from psql into a file

От
"Rob Arnold"
Дата:
Assuming you are on Linux/Unix:

psql YOURDBNAME -e < sqlscript.txt > output.txt 2>&1

The -e option echos the script too which is helpful when debugging.

On NT do this:

(see Q110930 for more info)

psql YOURDBNAME -e < sqlscript.txt 1> output.txt 2>&1

--rob


----------
From:  Huy Do [SMTP:huy@travel.com.au]
Sent:  Wednesday, December 20, 2000 12:37 AM
To:  pgsql-novice@postgresql.org
Subject:  Capturing all output from psql into a file

Hi,

I am doing this mass table creation (approx 600 tables) and then
mass dump of records into these tables (~900megs of flat files).

All the table creation and record copy is being done from a file
using \i sqlscript.txt.

How can I capture all the output which comes out from psql. I need
all the errors and not just the query result.

I have tried to use \o file.txt and \g file.txt but they only
seem to output the query result.

Many thanks.

Huy

Вложения

Re: Capturing all output from psql into a file

От
David Merrill
Дата:
On Wed, Dec 20, 2000 at 09:07:50AM -0000, Tamsin wrote:
> I use this:
>
> psql dbname -c "\i sqlscript.txt" &> file.txt
>
> (enter at shell prompt rather than going into psql first)

I am doing this also, from a shell script. I redirect the messages
into error.log, then the last line of my script is:

grep < error.log ERROR

which displays any errors that may have happened. This is how I deal
with the volume of NOTICE lines that I get, which would otherwise
obscure the ERROR lines.

--
Dr. David C. Merrill                     http://www.lupercalia.net
Linux Documentation Project                dmerrill@lupercalia.net
Collection Editor & Coordinator            http://www.linuxdoc.org
                                       Finger me for my public key

We all come from the Goddess
And to Her we shall return
Like a drop of rain
Flowing to the ocean