(Courriels de diversion: <contractons@remmena-eclaterions.com> <eruditions@secondaient-folioter.com> <inventrices@catalyserions-capitalisions.com> <embourgeoisant@insuffleriez-felicites.com> <receptionnee@syriennes-satisfaisons.com> <convoierai@sent-valorisiez.com> <mastiquions@soda-ridiculisant.com> <federeras@brechet-positives.com> <replets@reperde-vacarme.com> <relaye@surgelons-cartels.com> )



Bonjour.

j'ai le scprit suivant d'hylafax qui a été modifié pour envoyer par mail à
l'utilisateur, le pdf associé à l'envois d'un fax.
(script provenant de la mailing list hylafax)

En clair:
j'envois un fax
le serveur hylafax l'envois
il me notifie par mail que le fax a été envoyé
fonctionnalité en plus: j'ai en pièce jointe mon fax en fichier pdf.

tout fonctionne sauf que le pdf est corrompu, ou plutôt qu'il fait 0 octet

J'ai la version 4.1.8.
Je ne connais connais rien en programmtion mais j'ai l'impression que la
variable file[0], dans:

system("/usr/bin/ps2pdf12 " files[0] " /var/spool/fax/pdfs/fax.pdf
1>/dev/null 2>/dev/null");

ne contiens pas ce qu'il faut.

Par contre dans la boucle (j'ai décommenté):

#	if (nfiles > 0) {
#	    printBanner("Documents soumis à transmission");
#	    print "Les documents suivants ont été soumis à la transmission et
sont";
#	    print "disponibles sur le serveur jusqu à ce qu ils soient
automatiquement";
#	    print "supprimés lorsque ce fax est purgé (" doneop "d).  Les
documents peuvent aussi être supprimés manuellement";
#	    print "en utilisant la commande faxrm; consulter faxrm(1) pour
information.";
#	    print ""
#	    printf "%-20s %8s %s\n", "Fichier", "Taille", "Type";
#	    for (i = 0; i < nfiles; i++) {
#		"wc -c " files[i] | getline;
#		printf "%-20s %8d %s\n", files[i], $1, docType(files[i]);
#		close("wc -c " files[i]);
#	     }

il affiche dans la notification :

Les documents suivants ont été soumis à la transmission et sont
disponibles sur le serveur jusqu à ce qu ils soient automatiquement
supprimés lorsque ce fax est purgé (removed).  Les documents peuvent aussi
être supprimés manuellement
en utilisant la commande faxrm; consulter faxrm(1) pour information.

Fichier                Taille Type
docq/doc26.ps               0 PostScript

Pour le fichier ç'est correcte, mais pour la taille ça m'inquiète.

S'il vous plait de l'aide, je ne trouve pas de solution.


Merci
Nicolas M.

Le script:
#! /bin/sh
#	$Id: notify.awk,v 1.1.1.1 1998/10/12 20:47:48 root Exp $
#
# HylaFAX Facsimile Software
#
# Copyright (c) 1990-1996 Sam Leffler
# Copyright (c) 1991-1996 Silicon Graphics, Inc.
#
# 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.
#

#
# Awk support program for notify shell script.  This
# stuff is broken out into a separate file to avoid
# overflowing the exec arg list on some systems like SCO.
#

function printItem(fmt, tag, value)
{
    printf "%14s: " fmt "\n", tag, value;
}

function printBanner(banner)
{
    print "";
    print "    ---- " banner " ----";
    print "";
}

function docType(s)
{
    if (match(s, "\.cover"))
	return "PostScript cover page";
    else if (match(s, "\.ps"))
	return "PostScript";
    else if (match(s, "\.tif"))
	return "TIFF";
    else if (match(s, "\.pcl"))
	return "PCL";
    else
	return "Unknown document type";
}

#
# Construct a return-to-sender message.
#
function returnToSender()
{
#    printBanner("Unsent job status");
    printBanner("Etat du fax non émis");
    printItem("%s", "Destination", number);
    printItem("%s", "JobID", jobid);
    printItem("%s", "GroupID", groupid);
#    printItem("%s", "Sender", sender);
    printItem("%s", "Emetteur", sender);
#    printItem("%s", "Mailaddr", mailaddr);
    printItem("%s", "Addr. mail", mailaddr);
    if (commid != "")
	printItem("%s", "CommID", commid);
    if (modem != "any")
	printItem("%s", "Modem", modem);
    printItem("%s", "Soumis depuis", client);
    if (jobType == "facsimile") {
	printItem("%u (mm)", "Largeur page", pagewidth);
	printItem("%.0f (mm)", "Hauteur page", pagelength);
	printItem("%.0f (lpi)", "Résolution", resolution);
    }
    printItem("%s", "Status", status == "" ? "  (nothing available)" :
status);
    printItem("%u (échanges avec l'équipement distant)", "Dialogues",
tottries);
    printItem("%u (numérotations consécutives vers la destination)",
"Numérotations", ndials);
#    printItem("%u (total phone calls placed)", "Calls", totdials);
    printItem("%u (total appels tentés)", "Appels", totdials);
    if (jobType == "facsimile") {
#        printItem("%u (pages transmitted)", "Pages", npages);
	printItem("%u (pages transmises)", "Pages", npages);
	printItem("%u (total pages à transmettre)", "TotPages", totpages);
	printItem("%u (tentatives envoi page courante)", "Tentatives", ntries);
#	printItem("%u (repertoire prochaine page)", "Dirnum", dirnum);
#	if (nfiles > 0) {
#	    printBanner("Documents soumis à transmission");
#	    print "Les documents suivants ont été soumis à la transmission et
sont";
#	    print "disponibles sur le serveur jusqu à ce qu ils soient
automatiquement";
#	    print "supprimés lorsque ce fax est purgé (" doneop "d).  Les
documents peuvent aussi être supprimés manuellement";
#	    print "en utilisant la commande faxrm; consulter faxrm(1) pour
information.";
#	    print ""
#	    printf "%-20s %8s %s\n", "Fichier", "Taille", "Type";
#	    for (i = 0; i < nfiles; i++) {
#		"wc -c " files[i] | getline;
#		printf "%-20s %8d %s\n", files[i], $1, docType(files[i]);
#		close("wc -c " files[i]);
#	     }
#	}
     } else if (jobType == "pager") {
	if (npins != 0) {
	    printBanner("Pages en échec de transmission");
	    for (i = 0; i < npins; i++)
		printf "%15s\n",  "PIN " pins[i];
	}
	if (nfiles != 0) {
	    printBanner("Message text");
	    while ((getline <files[0]) > 0)
		print $0;
	    close(files[0]);
	}
    }
}

function returnTranscript()
{
    printBanner("Rapport de session ci-dessous");
    comFile = "log/c" commid;
    if ((getline <comFile) > 0) {
	do {
	    if (index($0, "-- data") == 0)
		print $0
	} while ((getline <comFile) > 0);
	close(comFile);
    } else {
	printf "    Aucun rapport disponible";
	if (commid != "")
	    printf "(CommID c" commid ")";
	print ".";
    }
}

function printStatus(s)
{
    if (s == "")
	print "<no reason recorded>";
    else
	print s
}

function putHeaders(subject)
{
    print "MIME-Version: 1.0";
    print "Content-Type: multipart/mixed;";
    print "	boundary=\"----=_NextPart_000_0012_01BF3CD4.528144C0\"";
    print "To: " mailaddr;
    print "Subject: " subject;
    print "";
    print "This is a multi-part message in MIME format.";
    print "";
    print "------=_NextPart_000_0012_01BF3CD4.528144C0";
    print "Content-Type: text/plain;";
    print "	charset=\"iso-8859-1\"";
    print "Content-Transfer-Encoding: 7bit";
    print "";
#    printf "Your " jobType " job to " number;
    printf "Votre fax vers " number;
}

BEGIN		{ nfiles = 0;
		  npins = 0;
		  pagewidth = 0;
		  pagelength = 0;
		  resolution = 0;
		  jobType = "facsimile";
		  signalrate = "unknown";
		  dataformat = "unknown";
		  doneop = "default";
                pagernum = "unknown";
		  commid = "";
		}
/^jobid/	{ jobid = $2; }
/^groupid/	{ groupid = $2; }
/^state/	{ state = $2+0; }
/^doneop/	{ doneop = $2; }
/^number/	{ number = $2; }
/^external/	{ number = $2; }		# override unprocessed number
/^sender/	{ sender = $2; }
/^mailaddr/	{ mailaddr = $2; }
/^jobtag/	{ jobtag = $2; }
/^jobtype/	{ jobType = $2; }
/^status/	{ status = $0; sub("status:", "", status);
		  if (status ~ /\\$/) {
		      sub("\\\\$", "\n", status);
		      while (getline > 0) {
			  status = status $0;
			  sub("\\\\$", "\n", status);
			  if ($0 !~ /\\$/)
			      break;
		      }
		  }
		}
/^resolution/	{ resolution = $2; }
/^npages/	{ npages = $2; }
/^totpages/	{ totpages = $2; }
/^dirnum/	{ dirnum = $2; }
/^commid/	{ commid = $2; }
/^ntries/	{ ntries = $2; }
/^ndials/	{ ndials = $2; }
/^pagewidth/	{ pagewidth = $2; }
/^pagelength/	{ pagelength = $2; }
/^signalrate/	{ signalrate = $2; }
/^dataformat/	{ dataformat = $2; }
/^modem/	{ modem = $2; }
/^totdials/	{ totdials = $2; }
/^tottries/	{ tottries = $2; }
/^client/	{ client = $2; }
/^[!]*post/	{ files[nfiles++] = $4; }
/^[!]*tiff/	{ files[nfiles++] = $4; }
/^[!]*pcl/	{ files[nfiles++] = $4; }
/^page:/	{ pins[npins++] = $4; }
/^[!]page:/   { pagernum = $4; }
/^data:/	{ files[nfiles++] = $4; }
/^poll/		{ poll = " -p"; }
END {
    if (jobtag == "")
	jobtag = jobType " job " jobid;;
    if (doneop == "default")
	doneop = "remove";
    if (jobType == "pager")
      number = pagernum;
    if (why == "done") {
#	putHeaders(jobtag " to " number " completed");
	putHeaders("Fax " jobtag " vers " number " envoyé");
#	print " was completed successfully.";
	print " a été envoyé correctement.";
	print "";
	if (jobType == "facsimile") {
	    printItem("%u", "Pages", npages);
	    if (resolution == 196)
		printItem("%s", "Qualitié", "Fine");
	    else
		printItem("%s", "Qualité", "Normale");
	    printItem("%u (mm)", "Largeur Page", pagewidth);
	    printItem("%.0f (mm)", "Hauteur Page", pagelength);
	    printItem("%s", "Vitesse", signalrate);
	    printItem("%s", "Format données", dataformat);
	}
	if (tottries != 1)
	    printItem("%s (échanges avec équipement distant)", "Dialogues",
tottries);
	if (totdials != 1)
#	    printItem("%s (total phone calls placed)", "Calls", totdials);
	    printItem("%s (total appels tentés)", "Appels", totdials);
	if (modem != "any")
	    printItem("%s", "Modem", modem);
	printItem("%s", "Soumis depuis", client);
	printItem("%s", "JobID", jobid);
	printItem("%s", "GroupID", groupid);
	printItem("%s", "CommID", "c" commid);
	printf "\nTemps total de traitement " jobTime ".\n";
	if (status != "") {
	    print "  Informations complémentaires:\n    " status;
	    returnTranscript();
	}
	print "------=_NextPart_000_0012_01BF3CD4.528144C0";
	print "Content-Type: application/pdf;";
	print "	name=\"" jobtag ".pdf\"";
	print "Content-Transfer-Encoding: base64";
	print "Content-Disposition: inline;";
	print "	filename=\"" jobtag ".pdf\"";
	print "";
	system("/usr/bin/ps2pdf " files[0] " /tmp/fax.pdf 1>/dev/null
2>/dev/null");

	system("/usr/bin/mimencode /tmp/fax.pdf");
	system("/bin/rm /tmp/fax.pdf");
#	print "------=_NextPart_000_0012_01BF3CD4.528144C0";

    } else if (why == "failed") {
	putHeaders("Fax " jobtag " vers " number " échoué");
	printf " a échoué. Raison de l'échec:\n    ";
	printStatus(status);
#	returnTranscript();
	returnToSender();

        print "------=_NextPart_000_0012_01BF3CD4.528144C0";
        print "Content-Type: application/pdf;";
        print " name=\"" jobtag ".pdf\"";
        print "Content-Transfer-Encoding: base64";
        print "Content-Disposition: inline;";
        print " filename=\"" jobtag ".pdf\"";
        print "";
        system("/usr/bin/ps2pdf " files[0] " /tmp/fax.pdf 1>/dev/null
2>/dev/null");

        system("/usr/bin/mimencode /tmp/fax.pdf");
        system("/bin/rm /tmp/fax.pdf");

    } else if (why == "rejected") {
	putHeaders("Fax " jobtag " vers " number " rejeté");
	printf " a été rejeté pour la raison suivante:\n    ";
	printStatus(status);
	returnToSender();
        print "------=_NextPart_000_0012_01BF3CD4.528144C0";
        print "Content-Type: application/pdf;";
        print " name=\"" jobtag ".pdf\"";
        print "Content-Transfer-Encoding: base64";
        print "Content-Disposition: inline;";
        print " filename=\"" jobtag ".pdf\"";
        print "";
        system("/usr/bin/ps2pdf " files[0] " /tmp/fax.pdf 1>/dev/null
2>/dev/null");

        system("/usr/bin/mimencode /tmp/fax.pdf");
        system("/bin/rm /tmp/fax.pdf");

    } else if (why == "blocked") {
	putHeaders("Fax " jobtag " vers " number " bloqué");
	printf " est différé à l envoi pour la raison suivante:\n    ";
	printStatus(status);
	print "";
	print "Ce fax va être traîté dès que possible."
        print "------=_NextPart_000_0012_01BF3CD4.528144C0";
        print "Content-Type: application/pdf;";
        print " name=\"" jobtag ".pdf\"";
        print "Content-Transfer-Encoding: base64";
        print "Content-Disposition: inline;";
        print " filename=\"" jobtag ".pdf\"";
        print "";
        system("/usr/bin/ps2pdf " files[0] " /tmp/fax.pdf 1>/dev/null
2>/dev/null");

        system("/usr/bin/mimencode /tmp/fax.pdf");
        system("/bin/rm /tmp/fax.pdf");

    } else if (why == "requeued") {
	putHeaders("Fax " jobtag " vers " number " remis en file d attente");
	printf " n'a pas été envoyé pour la raison suivante:\n    ";
	printStatus(status);
	print "";
	print "Nouvelle tentative à " nextTry "."
	returnTranscript();
    } else if (why == "removed" || why == "killed") {
	putHeaders("Fax " jobtag " vers " number " retiré de la file d attente");
	print " a été retiré de la file d attente.";
	if (why == "killed")
	    returnToSender();
    } else if (why == "timedout") {
	putHeaders("Fax " jobtag " vers " number " échoué");
	print " n a pas pas pu être envoyé avant l échéance prévue.(timeout)";
	returnToSender();
        print "------=_NextPart_000_0012_01BF3CD4.528144C0";
        print "Content-Type: application/pdf;";
        print " name=\"" jobtag ".pdf\"";
        print "Content-Transfer-Encoding: base64";
        print "Content-Disposition: inline;";
        print " filename=\"" jobtag ".pdf\"";
        print "";
        system("/usr/bin/ps2pdf " files[0] " /tmp/fax.pdf 1>/dev/null
2>/dev/null");

        system("/usr/bin/mimencode /tmp/fax.pdf");
        system("/bin/rm /tmp/fax.pdf");

    } else if (why == "format_failed") {
	putHeaders("Fax " jobtag " vers " number " échoué");
	print " n a pas été envoyé car la conversion du document"
	print "en fax a échoué.  Le diagnostic du convertisseur est:\n";
	print status "\n";
	printf "Vérifiez la validité de vos documents PostScript (police non
standard) %s.\n",
	    "et/ou syntaxe incorrecte";
	returnToSender();
        print "------=_NextPart_000_0012_01BF3CD4.528144C0";
        print "Content-Type: application/pdf;";
        print " name=\"" jobtag ".pdf\"";
        print "Content-Transfer-Encoding: base64";
        print "Content-Disposition: inline;";
        print " filename=\"" jobtag ".pdf\"";
        print "";
        system("/usr/bin/ps2pdf " files[0] " /tmp/fax.pdf 1>/dev/null
2>/dev/null");

        system("/usr/bin/mimencode /tmp/fax.pdf");
        system("/bin/rm /tmp/fax.pdf");

    } else if (why == "no_formatter") {
	putHeaders("Fax " jobtag " vers " number " échoué");
	print " n a pas pu être envoyé car";
	print "le scrpit de conversion n a pas été trouvé.";
	returnToSender();
    } else if (match(why, "poll_*")) {
	putHeaders("Note à propos de " jobtag);
	printf ", a polling request,\ncould not be completed because ";
	if (why == "poll_rejected")
	    print "the remote side rejected your request.";
	else if (why == "poll_no_document")
	    print "no document was available for retrieval.";
	else if (why == "poll_failed")
	    print "an unspecified problem occurred.";
	print "";
	printf "Processing time was %s.\n", jobTime;
	returnTranscript();
    } else {
	putHeaders("Notice about " jobtag);
	print " had something happen to it."
	print "Unfortunately, the notification script was invoked",
	    "with an unknown reason"
	print "so the rest of this message is for debugging:\n";
	print "why: " why;
	print "jobTime: " jobTime;
	print "nextTry: " nextTry;
	print  "";
	print "This should not happen, please report it to your administrator.";
	returnTranscript();
	returnToSender();
    }
}


--------------------------------------------------------------------
Les listes de diffusion occultes: <URL:http://www.CULTe.org/listes/>