[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

awk Hilfe gesucht (sambafax)



hi,

ein Script hat die Aufgabe die vom Samba Drucker Aufträge entgegen
zunehmen,
daraus eine Faxnummer zu extrahieren und an Hylafax abzusenden. Einige
werden es sicher kennen "sambafax".

Das Problem, es muss so abgeändert werden, das es mit einem WWS zusammen
arbeitet. Ein Freund konnte bei einem kleinen Teil schon helfen.

Ich hatte es zuerst mit einer Debug Version getest, was schon
funktionierte,
allerdings funktioniert das echte Script nicht auf die gleiche Art.

DEBUG-Script:

[...]
# now convert the to-be faxed data (PS format) to txt format
${PS2ASCII} ${DEBUGPS} >${DEBUGTXT}

# retrieve the faxnumber from the txtfile
FAXNUM=$( cat $DEBUGTXT | grep '@@NMR' | sed s/@@NMR\ // | sed s/\
.*$//) \
         {  $0=$0 "xxx"; \
            gsub(/-/,""); \
            anfang=match($0,/ ?: ?/); \
            anfang=anfang+match(substr($0,anfang),/[0-9]/)-1; \
            ende=match(substr($0,anfang),/[^0-9]/)-1; \
            printf ("%s",substr($0,anfang,ende)) \
         }' `
echo ""
echo "Faxnumber extracted: \"${FAXNUM}\"."

Dieses funktioniert, es wird die richtige Nummer ausgegeben.

Das muss bei dem echten Script auch so gehen:

# now dump the to-be faxewd data (PS fdormat) to the temp file
cat >${FAXFILE}       # this comes from the pipe (local mission)
cat $6 >>${FAXFILE}   # or this comes from samba as a file

# retrieve the faxnumber from the printfile
# the silly three x's are added because some awk strugle with an
immediate
CR
# we use a PS to ascii pipe to strip (most of) the Postscript controls
FAXNUM=`${PS2ASCII} ${FAXFILE} | ${AWK} '{ IGNORECASE=1 } /FAX-Nr ?:
?[0-9-]*/ \
         {  $0=$0 "xxx"; \
            gsub(/-/,""); \
            anfang=match($0,/ ?: ?/); \
            anfang=anfang+match(substr($0,anfang),/[0-9]/)-1; \
            ende=match(substr($0,anfang),/[^0-9]/)-1; \
            printf ("%s",substr($0,anfang,ende)) \
         }' `

Ich weiß leider nicht, wie ich das mit dem " `${PS2ASCII} ${FAXFILE} "
händeln soll. Ziel muss es sein, das die FaxNummer hinter @@NMR
extrahiert
wird.

Kann mir jemand da helfen?

cu denny
-- 
cu denny

Gnupg key can be found under pgp.mit.edu, key ID 0x73137598

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: