Category: Utilities
Author/Contact Info Frans la Cour (flc@metier.dk)
Description:
#Script to display modem logfiles on Win 9x/NT #Format of the logfile: #12-20-1999 16:13:13.53 - Interpreted response: Connect #12-20-1999 16:13:13.53 - Connection established at 128000bps. #... #12-20-1999 18:23:01.62 - Interpreted response: No Carrier #12-20-1999 18:23:02.21 - Hanging up the modem. #Outputs: #20-12-99 16:13:13 Connected for 0130 minutes at 128000bps
#!/perl/bin/perl.exe -w
use strict;


my $logfile = $ARGV[0] || 'C:\WINDOWS\Eicon DIVA T-A ISDN Modem Pnp.lo
+g';
my $conn = 'Connection established';     #The string identfying a logo
+n
my $hup = 'Hanging up';                    #The string identifying a h
+ang up
my (@conti, @hupti, $hours, $mins, $tot_mins, $num_con);
open(INFILE, "<$logfile") or die "Error opening file: $!";
while (<INFILE>) { 
     #Split in mm dd yyyy hh mm ss and connect speed
     @conti = (split(/ |-|:|\./))[0,1,2,3,4,5,12] if (/$conn/); 
     if (/$hup/ && $conti[5]) {
        @hupti = (split(/ |-|:|\./))[0,1,2,3,4,5];
        $num_con++;                     #The number of connections
        $hours = $hupti[3] - $conti[3]; #Calculate hours
        $hours += 24 if $hours < 0;
        $mins = ($hours * 60) + ($hupti[4] - $conti[4]);   #Calculate 
+minutes
        $tot_mins += $mins;
        printf "%02d-%02d-%02d",$conti[1],$conti[0],substr($conti[2],2
+); #Date
        printf " %02d:%02d:%02d Connected for ",$conti[3],$conti[4],$c
+onti[5];    #Time
        printf "%04d minutes ",$mins;
        printf "at %09s\n",$conti[6];
        undef @conti;
    }
}
close INFILE;
print "\nTotal number of connects: ";
printf "%04d \n",$num_con;
print "Total connect time: ";
printf "%06d minutes \n",$tot_mins;
print "Average connect time: ";
printf "%02d minutes \n", $tot_mins/$num_con;