Hi,

I need help simplified this code it doesnt meet my expectations for laziness.  I am 
trying to monitor printers that have jobs on the que4 older then 1 hour.  Basically 
this perl script reads the time stamp in the output q and parses it into a number.

Thsi code runs on my HP boxes and I do not have a lot of modules.  I do not have 
Date::Calc for example.

#!/usr/local/bin/perl5 -w
#name : lpstato.pl
#Purpose: find old print job
use Time::Local;
@month{"Aug","Sep","Oct"}=(7,8,9); # hash slice c onvert the  month into and array 
value.
@time=localtime(time-3600);  # save local time - 1hr as array values
$time=$time[4]*10000;  # roll up the array values into a number
$time=$time+($time[3]*100);
$time=$time+($time[2]);
#print $time
@lpstato=`lpstat -o`;  # read printer jobs on my server
foreach  (@lpstato) {  # loop thorgh and find the timstamp
if (/[A-Z][a-z][a-z]\s+[0-9][0-9]\s+[0-9][0-9]:[0-9][0-9]/) { # match the timestamp
($m,$d,$t)=split(/ /,$&);($h,$m1)=split(/:/,$t);  # parse out the timestamp
@date=localtime(timelocal('0',$m1,$h,$d,$month{$m},'2001'));  #populate array
$date=$date[4]*10000;  #once again roll up the time into a numeric value
$date=$date+($date[3]*100);
$date=$date+($date[2]);
#print $date
if ($date < $time){ print;}#compare the time value and if older then 1 hr print .
}
}



Thank You
Dennis Smith
SAP Tech Team
484 563 2389
[EMAIL PROTECTED]

_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users

Reply via email to