Re: Returned mail: User unknown
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@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Import Notes
Reply to msg id not found: 199908151352.JAA01241@candle.pha.pa.us
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@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026