#!/usr/bin/perl ################################################# # # Doc2ARS v1.0 # ################################################# # analyse et met en forme un fichier # de demande d intervention SFR suite # a son traitement par antiword ################################################# # 1.0 - S.YVON - Version initiale # ################################################# use strict; sub trim($); my $type = ""; my $descline = 0; my $description = ""; my $tmp = ""; my $desc = ""; my $ref = ""; my $bt = ""; my $docfile = $ARGV[0].".doc"; my $txtfile = $ARGV[0].".txt"; $tmp = `/usr/local/sbin/antiword $docfile > $txtfile`; open (F1, $txtfile); while () { # EN-TETE if ($_ =~ m/\|A.*\|(.*)\|/) { # A $tmp = trim($1); print "headera=$tmp;"; if ($tmp =~ "YYY") { $type = "YYY"; } else { $type = "XXX"; } print "headertype=$type;"; } if ($_ =~ m/\|Date.*\|(.*)\|/) { # Date $tmp = trim($1); print "headerdate=$tmp;"; } if ($_ =~ m/\|Objet.*\|(.*)\|/) { # Objet $tmp = trim($1); print "headerobjet=$tmp;"; } if ($_ =~ m/^N.*\:\s(\d{11})/) { # Num de Tache $tmp = trim($1); print "headernumtache=$tmp;"; } if ($_ =~ m/trompeur.*\:\s(.*)/) { # Detrompeur $tmp = trim($1); print "headerdetrompeur=$tmp;"; } # SITE if ($type eq "XXX" && $_ =~ m/[Nn]um.ro.*:\s*(\S*).*Classif/) { # Numero $tmp = trim($1); print "sitenum=$tmp;"; } elsif ($type eq "YYY" && $_ =~ m/[Nn]um.ro.*:\s*(\S*).*/) { # Numero $tmp = trim($1); print "sitenum=$tmp;"; } if ($_ =~ m/Classification.*(CLASSE..)/) { # Classification $tmp = trim($1); print "siteclasse=$tmp;"; } if ($_ =~ m/[Nn]om\s\:\s*(\S.*)/) { # Classification $tmp = trim($1); print "sitenom=$tmp;"; } # EQUIPEMENT if ($type eq "XXX" && $_ =~ m/type.*quipement.*\:\s*(.*)\s{2,}Objet.*\:\s(.*)$/) { # type d equipement $tmp = trim($1); print "equiptype=$tmp;"; $tmp = trim($2); print "equipobjet=$tmp;"; } elsif ($type eq "YYY" && $_ =~ m/type.*quipement.*\:\s*(\S*)/) { $tmp = trim($1); print "equiptype=$tmp;"; } if ($_ =~ m/ID\sEquipement.*\:\s(.*)/) { # ID Equipement $tmp = trim($1); print "equipid=$tmp;"; } if ($_ =~ m/fournisseur.*\:\s(.*)/) { # fournisseur $tmp = trim($1); print "equipfournisseur=$tmp;"; } # DESCRIPTION DE L'INCIDENT if ($_ =~ m/Impact.*(Non|Oui)/) { # Impact Client $tmp = trim($1); print "descimpact=$tmp;"; } if ($_ =~ m/Nbre.*\:\s(.*)Nbre/) { # Nbre de TCH HS $tmp = trim($1); print "descnbtchhs=$tmp;"; } if ($_ =~ m/Nbre.*UMTS.*\:\s(.*)/) { # Nbre de Cellule UMTS HS $tmp = trim($1); print "descnbumtshs=$tmp;"; } if ($_ =~ m/.ype.*incident.*\:\s(.*)$/) { # Type d'incident $tmp = trim($1); $desc = "ok"; print "desctypeincident=$tmp;"; } # DESCRIPTION if ($descline > 0) { $description = $description . " " . trim($_); } if ($_ =~ m/escription.*\:.*$/ && $desc eq "ok") { $descline = $.; } } $description = trim($description); print "description=$description;"; close (F1); $ref = `/usr/bin/strings $docfile | grep '^RES'`; chomp($ref); if ($ref =~ m/^(RES\d{7}).*/) { print("ref=$ref;"); } if ($type eq "YYY") { $bt = `/usr/bin/strings $docfile | grep '^: 00'`; chomp($bt); if ($bt =~ m/\:(.*)/) { $bt = trim($1); print("bt=$bt;"); } } print "\n"; sub trim($) { my $string = shift; $string =~ s/^\s+//; $string =~ s/\s+$//; return ($string); }