psql return code for NOTICE

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: psql return code for NOTICE
Date: 1999-08-15 14:12:52
Message-ID: 199908151412.KAA01682@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Actually I have several cron tasks and they bored me emailing
> every night output from psql.
> I need emails only if some problems occur.
> Ok. I could easily redirect all messages to some file if I would
> sure psql returns return code in right way. Then I could
> echo this file if RC != 0
> grep -v will not works because elog messages are printed to STDERR
> so I need something like:
> psql -q test < tt.sql 2>&1 | grep -v '^NOTICE:'
> but then I will lose return code from psql :-)
> Having several flags for different kind of messages would be
> very useful.

OK:

trap "rm -f /tmp/$$" 0 1 2 3 15
psql -q test < tt.sql >/tmp/$$ 2>&1
if [ "$?" -ne 0 ]
then echo "Failure"
fi
cat /tmp/$$ | grep -v '^NOTICE:'

Having different psql flags for different elog levels is a bit much.
psql already has too many flags.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message F J Cuberos 1999-08-15 14:28:03 Statement Triggers. Ideas & help.
Previous Message Bruce Momjian 1999-08-15 13:55:39 Re: Returned mail: User unknown