X-Original-To: pgadmin-hackers@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 34939476341; Fri, 28 Mar 2003 07:19:05 -0500 (EST) Received: from mailrelay1.lrz-muenchen.de (mailrelay1.lrz-muenchen.de [129.187.254.101]) by postgresql.org (Postfix) with ESMTP id C327247635A; Fri, 28 Mar 2003 07:19:03 -0500 (EST) Received: from [138.245.10.1] by mailout.lrz-muenchen.de; Fri, 28 Mar 2003 13:18:56 +0100 Message-Id: <003a01c2f524$3398b9b0$16e1f48a@IPSM7N> From: "rx" To: "Dave Page" , Cc: , "pgadmin-hackers" References: <03AF4E498C591348A42FC93DEA9661B86825@mail.vale-housing.co.uk> Subject: how can I get Error-message from postgresql in linux shell script Date: Fri, 28 Mar 2003 13:18:53 +0100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0036_01C2F52C.9481DCE0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Status: No, hits=-17.5 required=5.0 tests=BAYES_20,HTML_20_30,ORIGINAL_MESSAGE,QUOTED_EMAIL_TEXT, REFERENCES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200303/115 X-Sequence-Number: 943 This is a multi-part message in MIME format. ------=_NextPart_000_0036_01C2F52C.9481DCE0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0037_01C2F52C.9481DCE0" ------=_NextPart_001_0037_01C2F52C.9481DCE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Messagehallo, my Name is Rong. I am student at TU-Munich. I have some questions for Postgresql under SuSe Linux. I want save something in Postgresql-Table, when I get a fax from "Hylafax". I insert " psql -U postgres dbname < To: "rx" Sent: Thursday, March 27, 2003 4:03 PM Subject: Stalled post to pgsql-general > Your message to pgsql-general has been delayed, and requires the approval > of the moderators, for the following reason(s): > > Non-Member Submission from "rx" > > If you do not wish the message to be posted, or have other concerns, > please send a message to the list owners at the following address: > pgsql-general-owner@postgresql.org > ------=_NextPart_001_0037_01C2F52C.9481DCE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message
hallo,

my Name is Rong. I am student at TU-Munich. I have s= ome=20 questions for
Postgresql under SuSe Linux.

I want save something = in=20 Postgresql-Table, when I get a fax from "Hylafax".

I insert "
psql=20 -U postgres dbname <<END_OF_INSTR

insert into=20 "CSID_TIF"("CSID","suspens_file","actDatum")
values('0049891234567','tes= t.tif','01.01.2003'))

END_OF_INSTR=20 "

in shell script.

It work very good.

Now I want enhan= ce=20 it.

When there are some error in Postgresql, or There are some Error= at=20 insert,
I want give a message per email to me.

But I do not know,= =20 how  can I get the Error from Postgresql in Linux=20 Shell
Script.

When an Postgresql-Error is to happen, how can I ge= t the=20 Error-Message-Event
in shell script and send a email to me.

I hop= e I=20 can get your Help!

Thank you very much!

best=20 regards!

rong

PS: faxrcvd is my shell-script in Hylafax.
<= BR>#!=20 /bin/sh

psql -U postgres dbname <<END_OF_INSTR

insert i= nto=20 "CSID_TIF"("CSID","suspens_file","actDatum")
values('0049891234567','tes= t.tif','01.01.2003'))

END_OF_INSTR

##end=20 script

----- Original Message -----
From: <
pgsql-general-owner@postgresql.org>
To: "rx" <
rong.xie@stud.tu-muenchen.de>
Sent: Thursday, March 27, 2003 4:03 PM
Subject: Stalled= post=20 to pgsql-general


> Your message to pgsql-general has been del= ayed,=20 and requires the approval
> of the moderators, for the following=20 reason(s):
>
> Non-Member Submission from "rx" <
rong.xie@stud.tu-muenchen.de>
>
> If you do not wish the message to be posted, = or have=20 other concerns,
> please send a message to the list owners at the=20 following address:
>  
pgsql-general-owner@postgresql.org
>

= ------=_NextPart_001_0037_01C2F52C.9481DCE0-- ------=_NextPart_000_0036_01C2F52C.9481DCE0 Content-Type: application/octet-stream; name="faxrcvd" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="faxrcvd" #! /bin/sh echo "hallo" # $Id: faxrcvd.sh.in,v 1.1 2001/04/15 03:48:16 darren Exp $ # # HylaFAX Facsimile Software # # Copyright (c) 1990-1996 Sam Leffler # Copyright (c) 1991-1996 Silicon Graphics, Inc. # HylaFAX is a trademark of Silicon Graphics #=20 # Permission to use, copy, modify, distribute, and sell this software and= =20 # its documentation for any purpose is hereby granted without fee, provided # that (i) the above copyright notices and this permission notice appear in # all copies of the software and related documentation, and (ii) the names = of # Sam Leffler and Silicon Graphics may not be used in any advertising or # publicity relating to the software without the specific, prior written # permission of Sam Leffler and Silicon Graphics. # # THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, # EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY # WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. # # IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR # ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, # WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF # LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE # OF THIS SOFTWARE. # # # faxrcvd file devID commID error-msg destination # #if [ $# !=3D 5 ]; then # echo "Usage: $0 file devID commID error-msg destination" # exit 1 #fi echo "test1" test -f etc/setup.cache || { SPOOL=3D`pwd` cat</dev/null`" #if [ -f $FILE ]; then # # Check the sender's TSI and setup to dispatch # facsimile received from well-known senders. # SENDER=3D"`$INFO $FILE | $AWK -F: '/Sender/ { print $2 }' 2>/dev/null`" TXTFILE=3D`echo $FILE|sed -e 's/recvq//g; s/tif/txt/g'` TXTFILE=3D"/var/spool/fax/Eingang"$TXTFILE FILENAME=3D`echo $FILE|sed -e 's/recvq//g'|sed -e 's/\///'` $INFO $FILE > $TXTFILE chmod 0777 $TXTFILE echo $TXTFILE #####andert von rong 25.02.2003 Received=3D`sed -n -e '/Received:/p' $TXTFILE |sed 's/[\t\n\r\f\v]*Rece= ived: //g'|sed 's/:/\//'|sed 's/:/\//'` Sender=3D`sed -n -e '/Sender:/p' $TXTFILE |sed 's/[ \t\n\r\f\v]*Sender:= //g'` recvqsuspens=3D`sed -n -e '/recvq/p' $TXTFILE |cut -d/ -f2 |sed 's/://g= '` Received_file=3D`sed -n -e '/Received:/p' $TXTFILE|sed 's/[\t\n\r\f\v]*= Received: //g'|sed 's/:/_/g'|sed 's/ /_/g'|sed 's/_//'|sed 's/_//'` echo $Received_file #TIFFILE=3D`echo $FILE|sed -e 's/recvq//g'` #TIFFILE=3D"/var/spool/fax/Eingang"$TIFFILE #chmod 0777 $TIFFILE #TIFFILE=3D`echo $FILE|sed -e 's/recvq//g'` TIFFILE=3D$Received_file".tif" cp $FILE /var/spool/fax/Eingang/$TIFFILE #cp $FILE /var/spool/fax/Eingang/ chmod 0777 /var/spool/fax/Eingang/$TIFFILE echo $FILENAME echo $TIFFILE echo $recvqsuspens echo $Received echo $Sender psql -U postgres VEIrx <" # echo "Subject: facsimile received from $SENDER"; # echo "" # echo "$FILE (ftp://$HOSTNAME:$PORT/$FILE):"; $INFO -n $FILE # echo "ReceivedOn: $DEVICE" # if [ "$MSG" ]; then # echo "" # echo "The full document was not received because:" # echo "" # echo " $MSG" # echo "" # echo " ---- Transcript of session follows ----" # echo "" # if [ -f log/c$COMMID ]; then # $SED -e '/-- data/d' \ # -e '/start.*timer/d' -e '/stop.*timer/d' \ # log/c$COMMID # elif [ -n "$COMMID" ]; then # echo " No transcript available (CommID c$COMMID)." # else # echo " No transcript available." # fi # else # echo "CommID: c$COMMID (ftp://$HOSTNAME:$PORT/log/c$COMMID)" # fi # if [ -n "$SENDTO" ]; then # echo "" # echo "The facsimile was automatically dispatched to: $SENDTO." # fi # ) | 2>&1 $SENDMAIL -ffax -oi $TOADDR # if [ -n "$SENDTO" ]; then # (MIMEBOUNDARY=3D"NextPart$$" # echo "Mime-Version: 1.0" # echo "Content-Type: Multipart/Mixed; Boundary=3D\"$MIMEBOUNDARY\"" # echo "Content-Transfer-Encoding: 7bit" # echo "To: $SENDTO" # echo "From: The HylaFAX Receive Agent " # echo "Subject: facsimile received from $SENDER"; # echo "" # echo "--$MIMEBOUNDARY" # echo "Content-Type: text/plain; charset=3Dus-ascii" # echo "Content-Transfer-Encoding: 7bit" # echo "" # echo "$FILE (ftp://$HOSTNAME:$PORT/$FILE):"; $INFO -n $FILE # echo "ReceivedOn: $DEVICE" # if [ "$MSG" ]; then # echo "" # echo "The full document was not received because:" # echo "" # echo " $MSG" # echo "" # echo " ---- Transcript of session follows ----" # echo "" # if [ -f log/c$COMMID ]; then # $SED -e '/-- data/d' \ # -e '/start.*timer/d' -e '/stop.*timer/d' \ # log/c$COMMID # elif [ -n "$COMMID" ]; then # echo " No transcript available (CommID c$COMMID)." # else # echo " No transcript available." # fi # else # echo "CommID: c$COMMID (ftp://$HOSTNAME:$PORT/log/c$COMMID)" # fi # echo "" # echo "--$MIMEBOUNDARY" # echo "Content-Type: application/postscript" # echo "Content-Description: FAX document" # echo "Content-Transfer-Encoding: 7bit" # echo ""kwrite # $FAX2PS $FILE 2>/dev/null # echo "" # echo "--$MIMEBOUNDARY--" # ) | 2>&1 $SENDMAIL -ffax -oi $SENDTO # fi #else # # Generate notification mail for a failed attempt. # # echo "To:" # (echo "To: $TOADDR" # echo "From: The HylaFAX Receive Agent " # echo "Subject: facsimile not received" # echo "" # echo "An attempt to receive facsimile on $DEVICE failed because:" # echo "" # echo " $MSG" # echo "" # echo " ---- Transcript of session follows ----" # echo "" # if [ -f log/c$COMMID ]; then # $SED -e '/-- data/d' \ # -e '/start.*timer/d' -e '/stop.*timer/d' \ # log/c$COMMID # elif [ -n "$COMMID" ]; then # echo "No transcript available (CommID c$COMMID)." # else # echo "No transcript available." # fi # ) | 2>&1 $SENDMAIL -ffax -oi $TOADDR #fi ##end script ------=_NextPart_000_0036_01C2F52C.9481DCE0--