public inbox for [email protected]  
help / color / mirror / Atom feed
Re: [pgadmin-support] pgadtransport Procedural and Function from MS SQL Enterprise Manage to PostgreSQL
4+ messages / 2 participants
[nested] [flat]

* Re: [pgadmin-support] pgadtransport Procedural and Function from MS SQL Enterprise Manage to PostgreSQL
@ 2002-09-17 09:07 Dave Page <[email protected]>
  2003-03-28 12:16 ` Re: [pgadmin-support] pgadtransport Procedural and Function from MS SQL Enterprise Manage to PostgreSQL rx <[email protected]>
  2003-03-28 12:18 ` how can I get Error-message from postgresql in linux shell script rx <[email protected]>
  2003-03-28 12:23 ` how can I get Error-message from postgresql in linux shell script rx <[email protected]>
  0 siblings, 3 replies; 4+ messages in thread

From: Dave Page @ 2002-09-17 09:07 UTC (permalink / raw)
  To: XIE, Rong <[email protected]>; pgsql-docs; +Cc: [email protected]; pgadmin-hackers <[email protected]>

You will have to port your functions and procedures manually I'm afraid.
 
Regards, Dave.

	-----Original Message-----
	From: XIE, Rong [mailto:[email protected]] 
	Sent: 17 September 2002 09:59
	To: [email protected]
	Subject: [pgadmin-support] transport Procedural and Function from MS SQL Enterprise Manage to PostgreSQL 
	
	
	hallo,

	I have PostgreSQL in Linux. I use it with pgAdminII in Wondows2000.
	how can I transport Procedural and Function from MS SQL Enterprise Manage to
	PostgreSQL.
	Thanks!!!
	rong
	
	
	CREATE FUNCTION dbo.getICNroh (@Bogen_Nr smallint)
	RETURNS smallint AS
	BEGIN
	    DECLARE @myRet int
	--Rohwert der Skala 1 (ICN) ermitteln
	    DECLARE @step01a smallint
	    DECLARE @step02a smallint
	
	    DECLARE @step01b smallint
	    DECLARE @step02b smallint
	
	    SELECT @step01a = Antwort FROM PAI_ANTWORTEN WHERE ITEM_NR = 75 AND
	Bogen_Nr = @Bogen_Nr
	    SELECT @step01b = Antwort FROM PAI_ANTWORTEN WHERE ITEM_NR = 115 AND
	Bogen_Nr = @Bogen_Nr
	
	    SELECT @step02a = Antwort FROM PAI_ANTWORTEN WHERE ITEM_NR = 4 AND
	Bogen_Nr = @Bogen_Nr
	    SELECT @step02b = Antwort FROM PAI_ANTWORTEN WHERE ITEM_NR = 44 AND
	Bogen_Nr = @Bogen_Nr
	
	
	    SELECT @myRet = ABS(@Step01a - @step01b)
	              + ABS(@Step02a - @step02b)
	
	--Wert zurückgeben
	    RETURN @myRet
	END
	
	
	
	
	
	
	CREATE PROCEDURE sp_PAI_Werte
	    @Bogen_Nr int
	 AS
	
	
	create table #tmpPAI_Rohwerte (Skala_Nr smallint primary key, Rohwert
	smallint)
	
	--Rohwerte ermitteln (außer Skala 1 ICN)
	INSERT into #tmpPAI_Rohwerte
	SELECT dbo.PAI_SKALEN.Skala_Nr, sum((CONVERT(tinyint,
	                      dbo.PAI_ANTWORTEN.Antwort) + dbo.PAI_KEYcalc.toAdd) *
	dbo.PAI_KEYcalc.Faktor) AS Rohwert
	FROM dbo.PAI_SKALEN INNER JOIN
	                      dbo.PAI_ITEMinSKALA ON dbo.PAI_SKALEN.Skala_Nr =
	dbo.PAI_ITEMinSKALA.Skala_Nr INNER JOIN
	                      dbo.PAI_ITEMS ON dbo.PAI_ITEMinSKALA.Item_Nr =
	dbo.PAI_ITEMS.Item_Nr INNER JOIN
	                      dbo.PAI_ANTWORTEN ON dbo.PAI_ITEMS.Item_Nr =
	dbo.PAI_ANTWORTEN.Item_Nr INNER JOIN
	                      dbo.PAI_KEYcalc ON dbo.PAI_ITEMinSKALA.keyDir =
	dbo.PAI_KEYcalc.keyDir
	WHERE (dbo.PAI_ANTWORTEN.Antwort <> ' ') and PAI_Antworten.Bogen_Nr =
	@Bogen_Nr
	GROUP BY dbo.PAI_SKALEN.Skala_Nr
	
	--ICN Rohwert einfügen
	IF EXISTS(SELECT * from #tmpPAI_Rohwerte WHERE Skala_Nr = 1)
	    UPDATE #tmpPAI_Rohwerte SET Rohwert = dbo.getICNroh(@Bogen_Nr) WHERE
	Skala_Nr = 1
	ELSE
	    INSERT INTO #tmpPAI_Rohwerte (Skala_Nr, Rohwert)
	VALUES(1,dbo.getICNroh(@Bogen_Nr))
	
	--T-Werte bereitstellen
	SELECT dbo.PAI_SKALEN.Skala_Nr, dbo.PAI_SKALEN.Kuerzel_D AS Kuerzel,
	dbo.PAI_SKALEN.Label_D AS Label, #tmpPAI_Rohwerte.rohwert as rohwert,
	                      ROUND(50 + (#tmpPAI_Rohwerte.rohwert -
	dbo.PAI_SKALEN.M) *10 / dbo.PAI_SKALEN.SD, 0) AS TWert
	FROM dbo.PAI_SKALEN LEFT OUTER JOIN
	                      #tmpPAI_Rohwerte ON dbo.PAI_SKALEN.Skala_Nr =
	#tmpPAI_Rohwerte.skala_nr
	GO
	
	
	



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [pgadmin-support] pgadtransport Procedural and Function from MS SQL Enterprise Manage to PostgreSQL
  2002-09-17 09:07 Re: [pgadmin-support] pgadtransport Procedural and Function from MS SQL Enterprise Manage to PostgreSQL Dave Page <[email protected]>
@ 2003-03-28 12:16 ` rx <[email protected]>
  2 siblings, 0 replies; 4+ messages in thread

From: rx @ 2003-03-28 12:16 UTC (permalink / raw)
  To: Dave Page <[email protected]>; pgsql-docs; +Cc: [email protected]; pgadmin-hackers <[email protected]>

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 <<END_OF_INSTR

insert into "CSID_TIF"("CSID","suspens_file","actDatum")
values('0049891234567','test.tif','01.01.2003'))

END_OF_INSTR "

in shell script.

It work very good.

Now I want enhance it.

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

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

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

I hope I can get your Help!

Thank you very much!

best regards!

rong

PS: faxrcvd is my shell-script in Hylafax.

#! /bin/sh

psql -U postgres dbname <<END_OF_INSTR

insert into "CSID_TIF"("CSID","suspens_file","actDatum")
values('0049891234567','test.tif','01.01.2003'))

END_OF_INSTR

##end script

----- Original Message -----
From: <[email protected]>
To: "rx" <[email protected]>
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" <[email protected]>
>
> 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:
>   [email protected]
>



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* how can I get Error-message from postgresql in linux shell script
  2002-09-17 09:07 Re: [pgadmin-support] pgadtransport Procedural and Function from MS SQL Enterprise Manage to PostgreSQL Dave Page <[email protected]>
@ 2003-03-28 12:18 ` rx <[email protected]>
  2 siblings, 0 replies; 4+ messages in thread

From: rx @ 2003-03-28 12:18 UTC (permalink / raw)
  To: Dave Page <[email protected]>; pgsql-docs; +Cc: [email protected]; pgadmin-hackers <[email protected]>

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 <<END_OF_INSTR

insert into "CSID_TIF"("CSID","suspens_file","actDatum")
values('0049891234567','test.tif','01.01.2003'))

END_OF_INSTR "

in shell script.

It work very good.

Now I want enhance it.

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

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

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

I hope I can get your Help!

Thank you very much!

best regards!

rong

PS: faxrcvd is my shell-script in Hylafax.

#! /bin/sh

psql -U postgres dbname <<END_OF_INSTR

insert into "CSID_TIF"("CSID","suspens_file","actDatum")
values('0049891234567','test.tif','01.01.2003'))

END_OF_INSTR

##end script

----- Original Message -----
From: <[email protected]>
To: "rx" <[email protected]>
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" <[email protected]>
>
> 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:
>   [email protected]
>



Attachments:

  [application/octet-stream] faxrcvd (7.1K, 3-faxrcvd)
  download

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* how can I get Error-message from postgresql in linux shell script
  2002-09-17 09:07 Re: [pgadmin-support] pgadtransport Procedural and Function from MS SQL Enterprise Manage to PostgreSQL Dave Page <[email protected]>
@ 2003-03-28 12:23 ` rx <[email protected]>
  2 siblings, 0 replies; 4+ messages in thread

From: rx @ 2003-03-28 12:23 UTC (permalink / raw)
  To: Dave Page <[email protected]>; XIE, Rong <[email protected]>; pgsql-docs; +Cc: [email protected]; pgadmin-hackers <[email protected]>

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 <<END_OF_INSTR

insert into "CSID_TIF"("CSID","suspens_file","actDatum")
values('0049891234567','test.tif','01.01.2003'))

END_OF_INSTR "

in shell script.

It work very good.

Now I want enhance it.

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

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

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

I hope I can get your Help!

Thank you very much!

best regards!

rong

PS: faxrcvd is my shell-script in Hylafax.

#! /bin/sh

psql -U postgres dbname <<END_OF_INSTR

insert into "CSID_TIF"("CSID","suspens_file","actDatum")
values('0049891234567','test.tif','01.01.2003'))

END_OF_INSTR

##end script

----- Original Message -----
From: <[email protected]>
To: "rx" <[email protected]>
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" <[email protected]>
>
> 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:
>   [email protected]
>


#! /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
# 
# Permission to use, copy, modify, distribute, and sell this software and 
# 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 [ $# != 5 ]; then
#    echo "Usage: $0 file devID commID error-msg destination"
#    exit 1
#fi

echo "test1"

test -f etc/setup.cache || {
    SPOOL=`pwd`
    cat<<EOF

FATAL ERROR: $SPOOL/etc/setup.cache is missing!

The file $SPOOL/etc/setup.cache is not present.  This
probably means the machine has not been setup using the faxsetup(8C)
command.  Read the documentation on setting up HylaFAX before you
startup a server system.

EOF
    exit 1
}


echo $SPOOL

. etc/setup.cache
echo "etc/setup"
###INFO=/usr/sbin/faxinfo
INFO=$SBIN/faxinfo
echo $INFO
###FAX2PS=$TIFFBIN/fax2ps
TOADDR=FaxMaster
#
# There is no good portable way to find out the fully qualified
# domain name (FQDN) of the host or the TCP port for the hylafax
# service so we fudge here.  Folks may want to tailor this to
# their needs; e.g. add a domain or use localhost so the loopback
# interface is used.
#
HOSTNAME="localhost"			# XXX no good way to find FQDN
PORT=4559				# XXX no good way to lookup service

FILE="$1"
DEVICE="$2"
COMMID="$3"
MSG="$4"
echo $FILE
SENDER="`$INFO $FILE | $AWK -F: '/Sender/ { print $2 }' 2>/dev/null`"

#if [ -f $FILE ]; then
    #
    # Check the sender's TSI and setup to dispatch
    # facsimile received from well-known senders.
    #
    SENDER="`$INFO $FILE | $AWK -F: '/Sender/ { print $2 }' 2>/dev/null`"

    TXTFILE=`echo $FILE|sed -e 's/recvq//g; s/tif/txt/g'`
    TXTFILE="/var/spool/fax/Eingang"$TXTFILE
    FILENAME=`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=`sed -n -e '/Received:/p' $TXTFILE |sed 's/[\t\n\r\f\v]*Received: //g'|sed 's/:/\//'|sed 's/:/\//'`
    Sender=`sed -n -e '/Sender:/p' $TXTFILE |sed 's/[ \t\n\r\f\v]*Sender: //g'`
    recvqsuspens=`sed -n -e '/recvq/p' $TXTFILE |cut -d/ -f2 |sed 's/://g'`

    Received_file=`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=`echo $FILE|sed -e 's/recvq//g'`
    #TIFFILE="/var/spool/fax/Eingang"$TIFFILE
    #chmod 0777 $TIFFILE
    #TIFFILE=`echo $FILE|sed -e 's/recvq//g'`
    TIFFILE=$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 <<END_OF_INSTR

insert into "Faxeingang" values(trim(both ' ' from '$Received'),'$TIFFILE','$Sender')

END_OF_INSTR

    #####andert von rong 25.02.2003
#    SENDTO=
#    if [ -f bin/FaxDispatch ]; then
#	. bin/FaxDispatch	# NB: FaxDispatch sets SENDTO based on $5
#    fi
#    (echo "To: $TOADDR"
#     echo "From: The HylaFAX Receive Agent <fax>"
#     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="NextPart$$"
#	 echo "Mime-Version: 1.0"
#	 echo "Content-Type: Multipart/Mixed; Boundary=\"$MIMEBOUNDARY\""
#	 echo "Content-Transfer-Encoding: 7bit"
#	 echo "To: $SENDTO"
#	 echo "From: The HylaFAX Receive Agent <fax>"
#	 echo "Subject: facsimile received from $SENDER";
#	 echo ""
#	 echo "--$MIMEBOUNDARY"
#	 echo "Content-Type: text/plain; charset=us-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 <fax>"
#     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


Attachments:

  [text/plain] faxrcvd.txt (7.1K, 3-faxrcvd.txt)
  download | inline:
#! /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
# 
# Permission to use, copy, modify, distribute, and sell this software and 
# 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 [ $# != 5 ]; then
#    echo "Usage: $0 file devID commID error-msg destination"
#    exit 1
#fi

echo "test1"

test -f etc/setup.cache || {
    SPOOL=`pwd`
    cat<<EOF

FATAL ERROR: $SPOOL/etc/setup.cache is missing!

The file $SPOOL/etc/setup.cache is not present.  This
probably means the machine has not been setup using the faxsetup(8C)
command.  Read the documentation on setting up HylaFAX before you
startup a server system.

EOF
    exit 1
}


echo $SPOOL

. etc/setup.cache
echo "etc/setup"
###INFO=/usr/sbin/faxinfo
INFO=$SBIN/faxinfo
echo $INFO
###FAX2PS=$TIFFBIN/fax2ps
TOADDR=FaxMaster
#
# There is no good portable way to find out the fully qualified
# domain name (FQDN) of the host or the TCP port for the hylafax
# service so we fudge here.  Folks may want to tailor this to
# their needs; e.g. add a domain or use localhost so the loopback
# interface is used.
#
HOSTNAME="localhost"			# XXX no good way to find FQDN
PORT=4559				# XXX no good way to lookup service

FILE="$1"
DEVICE="$2"
COMMID="$3"
MSG="$4"
echo $FILE
SENDER="`$INFO $FILE | $AWK -F: '/Sender/ { print $2 }' 2>/dev/null`"

#if [ -f $FILE ]; then
    #
    # Check the sender's TSI and setup to dispatch
    # facsimile received from well-known senders.
    #
    SENDER="`$INFO $FILE | $AWK -F: '/Sender/ { print $2 }' 2>/dev/null`"

    TXTFILE=`echo $FILE|sed -e 's/recvq//g; s/tif/txt/g'`
    TXTFILE="/var/spool/fax/Eingang"$TXTFILE
    FILENAME=`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=`sed -n -e '/Received:/p' $TXTFILE |sed 's/[\t\n\r\f\v]*Received: //g'|sed 's/:/\//'|sed 's/:/\//'`
    Sender=`sed -n -e '/Sender:/p' $TXTFILE |sed 's/[ \t\n\r\f\v]*Sender: //g'`
    recvqsuspens=`sed -n -e '/recvq/p' $TXTFILE |cut -d/ -f2 |sed 's/://g'`

    Received_file=`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=`echo $FILE|sed -e 's/recvq//g'`
    #TIFFILE="/var/spool/fax/Eingang"$TIFFILE
    #chmod 0777 $TIFFILE
    #TIFFILE=`echo $FILE|sed -e 's/recvq//g'`
    TIFFILE=$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 <<END_OF_INSTR

insert into "Faxeingang" values(trim(both ' ' from '$Received'),'$TIFFILE','$Sender')

END_OF_INSTR

    #####andert von rong 25.02.2003
#    SENDTO=
#    if [ -f bin/FaxDispatch ]; then
#	. bin/FaxDispatch	# NB: FaxDispatch sets SENDTO based on $5
#    fi
#    (echo "To: $TOADDR"
#     echo "From: The HylaFAX Receive Agent <fax>"
#     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="NextPart$$"
#	 echo "Mime-Version: 1.0"
#	 echo "Content-Type: Multipart/Mixed; Boundary=\"$MIMEBOUNDARY\""
#	 echo "Content-Transfer-Encoding: 7bit"
#	 echo "To: $SENDTO"
#	 echo "From: The HylaFAX Receive Agent <fax>"
#	 echo "Subject: facsimile received from $SENDER";
#	 echo ""
#	 echo "--$MIMEBOUNDARY"
#	 echo "Content-Type: text/plain; charset=us-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 <fax>"
#     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

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2003-03-28 12:23 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-09-17 09:07 Re: [pgadmin-support] pgadtransport Procedural and Function from MS SQL Enterprise Manage to PostgreSQL Dave Page <[email protected]>
2003-03-28 12:16 ` rx <[email protected]>
2003-03-28 12:18 ` how can I get Error-message from postgresql in linux shell script rx <[email protected]>
2003-03-28 12:23 ` how can I get Error-message from postgresql in linux shell script rx <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox