Re: Returned mail: User unknown - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Returned mail: User unknown
Date
Msg-id 199908151355.JAA01342@candle.pha.pa.us
Whole thread Raw
In response to Returned mail: User unknown  (Mail Delivery Subsystem <MAILER-DAEMON@hotzsun.jpl.nasa.gov> (by way of Henry B. Hotz))
Responses psql return code for NOTICE
List 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 15psql -q test < tt.sql >/tmp/$$ 2>&1 if [ "$?" -ne 0 ]then    echo "Failure"ficat /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@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] How to get 'psql -q' runs really quiet ?
Next
From: Bruce Momjian
Date:
Subject: psql return code for NOTICE