From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Andrew Lapides <aal111(at)yahoo(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: catching script errors in PSQL and redirecting to file? |
Date: | 2004-12-15 06:47:19 |
Message-ID: | 20041215064719.GA29723@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Dec 14, 2004 at 09:25:19AM -0800, Andrew Lapides wrote:
> I tried the second option, i.e. calling psql from the command
> line redirecting output to the file:
>
> psql -U ... -W all_tables.sql > log
>
> Again not everything is recorded into the log file.
Some messages go to standard error, so you'll need to redirect that
as well:
psql ... > log 2>&1 (Bourne shell & friends)
psql ... >& log (C shell & friends)
Another possibility would be to use the "script" command from the
shell:
script log
psql ...
exit
grep ERROR log
> In my particular case I am recreating my schema on and on from
> scratch. With other databases I am used to running one script,
> checking the output file (for example with grep) for the majic word
> 'ERROR'. Please help.
If you're not interested in NOTICE messages like "CREATE TABLE will
create implicit sequence" then you could use client_min_messages
to filter them out:
SET client_min_messages TO ERROR;
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Eric Brown | 2004-12-15 08:19:14 | Running functions that return void in psql |
Previous Message | Frans | 2004-12-15 06:15:49 | Re: Connect to Postgres 7.4 via ODBC |