Difference between revisions of "As400pscript"
(One intermediate revision by the same user not shown) | |||
Line 44: | Line 44: | ||
#like Fax : 1234567, not Fax: 1234567 or similar. | #like Fax : 1234567, not Fax: 1234567 or similar. | ||
− | FAXNUMBER=`sed -ne '/'Fax'/{s/^.*'Fax' : *//g;s/[()]//g;s/[^0-9]\{1,\}.*^M$//g;p;q;}' | + | FAXNUMBER=`sed -ne '/'Fax'/{s/^.*'Fax' : *//g;s/[()]//g;s/[^0-9]\{1,\}.*^M$//g;p;q;}' < /tmp/as.$$` |
if [ "$FAXNUMBER" = "" ] ; then | if [ "$FAXNUMBER" = "" ] ; then | ||
Line 83: | Line 83: | ||
rm -f /tmp/as.$$ $FILE_AS400 $FILE_T $FILE_PS | rm -f /tmp/as.$$ $FILE_AS400 $FILE_T $FILE_PS | ||
− | + | </pre> |
Latest revision as of 09:33, 27 July 2007
#!/bin/sh cat - > /tmp/as.$$ Username="$1" FILE_AS400=/tmp/as1.$$ FILE_T=/tmp/as2.$$ FILE_PS=/tmp/ps.$$ SENDMAIL="/usr/sbin/sendmail" #TIFFBIN="/usr/bin" | #MIMENCODE=/usr/bin/mimencode | #PS2PDF=$TIFFBIN/ps2pdf <-------- For email notifications with the file,in PDF format # |attached. # At the beginning I thought that will be important to check if thefile exists, # but I realise that the file will never fail. But the line remains here, if later # proves to be necessary. # #if [ -s /tmp/as.$$ ] ; then #Here is where we merge the text from AS400 with the company logo, #stored in a file in ENCAPSULATED POSTSCRIPT format. Pay attention, #in EPS format! This is very important to work correctly. #Some tricks are made to work here so, if not work for you just #ask. Thanks goes for Giulio Orsero for is asistance. LANG=en_US col -b < /tmp/as.$$ > $FILE_AS400 echo -e "\000epsf[x0ca y0ca nx ny ]{COMPANYLOGO.eps}" > $FILE_T cat $FILE_AS400 >> $FILE_T /usr/bin/enscript -B -e $FILE_T -p $FILE_PS #Our users login in AS400 are in uppercase and to not duplicate #entrys I change them to lowercase UNAME=`echo "$Username" | sed -ne '/'-A'/{s/^.*'-A'//g;s/@.*//g;p;q;}' | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` #Fax number extracted from the text. The text should have an entry #like Fax : 1234567, not Fax: 1234567 or similar. FAXNUMBER=`sed -ne '/'Fax'/{s/^.*'Fax' : *//g;s/[()]//g;s/[^0-9]\{1,\}.*^M$//g;p;q;}' < /tmp/as.$$` if [ "$FAXNUMBER" = "" ] ; then (MIMEBOUNDARY="NextPart$$" echo "Mime-Version: 1.0" echo "Content-Type: Multipart/Mixed; Boundary=\"$MIMEBOUNDARY\"" echo "Content-Transfer-Encoding: 7bit" echo "To: $UNAME@yourhost" echo "From: Fax Server<fax>" echo "Subject: Outgoing fax job failure" echo "" echo "--$MIMEBOUNDARY"; echo "" echo "You request could not be completed!" echo `date` echo "" echo "" echo "Please, check if the fax number is missing openning the file attached." echo "" echo "--$MIMEBOUNDARY"; echo "Content-Type: application/postscript; name=$FNAME"; echo "Content-Description: FAX document;"; echo "Content-Disposition: inline;"; echo "Content-Transfer-Encoding: 7bit"; echo ""; cat $FILE_PS echo ""; echo "--$MIMEBOUNDARY--"; echo ""; ) | 2>&1 $SENDMAIL -ffax -oi $UNAME@yourhost else sendfax -n -D -f $UNAME@yourhost -d $FAXNUMBER $FILE_PS fi rm -f /tmp/as.$$ $FILE_AS400 $FILE_T $FILE_PS