Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'm looking for Perl solution to monitor execution status of Win32 task scheduler, like 'status' and 'last result'. It seems there are two solutions: Win32::Lanman and Win32::AdminMisc. I have downloaded the code. It runs silently, nothing back. Codes listed for your reference. Any feedback will be greatly appreciated!
#============================= # Win32::AdminMisc #============================= use win32::adminmisc; $Jobs = Win32::AdminMisc::ScheduleList("\\\\server01", \%Jobs); print "==>".%Jobs."\n"; foreach $Number (keys(%Jobs)){ print "Job $Number is $Jobs{$Number}->{Command}\n"; }
#============================= # Win32::Lanman #============================= use Win32::Lanman; use Win32::NetAdmin; @ARGV[0]; if (@ARGV[0] eq ""){print "\n\nSyntax\n\n\ttasks.pl servername\n\ttask +s.pl all\n\n"; exit 1;} if ("\U@ARGV[0]\E" eq "ALL"){&getservers;} else {@servers = ("@ARGV[0] +");} $output = "C:\\temp\\task.txt"; open(OUTPUT, ">$output") || die "Can't open $output"; %DOW = ( 0,'', 1,'Monday', 2,'Tuesday', 4,'Wednesday', 8,'Thursday', 16,'Friday', 32,'Saturday', 64,'Sunday' ); %DOM = ( 0,'', 1,'1', 2,'2', 4,'3', 8,'4', 16,'5', 32,'6', 64,'7', 128,'8', 256,'9', 512,'10', 1024,'11', 2048,'12', 4096,'13', 8192,'14', 16384,'15', 32768,'16', 65536,'17', 131072,'18', 262144,'19', 524288,'20', 1048576,'21', 2097152,'22', 4194304,'23', 8388608,'24', 16777216,'25', 33554432,'26', 67108864,'27', 134217728,'28', 268435456,'29', 536870912,'30', 1073741824,'31' ); %FLAG = ( 1,'Reoccuring job - Interactive', 3,'Reoccuring job - Interactive - Error when last run', 4,'One time job - Will run today - Interactive', 5,'Reoccuring job - Will run today - Interactive', 17,'Reoccuring job - Non-Interactive', 19,'Reoccuring job - Not Interactive - Error when last run', 20,'One time job - Will run today - Not Interactive', 21,'Reoccuring job - Will run today - Not Interactive' ); foreach $server (@servers) { print "querying $server\n"; if(!Win32::Lanman::NetScheduleJobEnum("\\\\$server", \@jobs)) { print "\n\nUnable to read scheduled jobs from $server\n\n"; next; } print "==>".@jobs."\n"; foreach $job (@jobs) { print OUTPUT "server = $server\n"; @keys = keys %$job; $job->{'daysofweek'} = $DOW{$job->{'daysofweek'}}; $job->{'daysofmonth'} = $DOM{$job->{'daysofmonth'}}; $job->{'flags'} = $FLAG{$job->{'flags'}}; $runtime = ${$job}{'jobtime'}/1000; $hour = sprintf("%02d", (int ($runtime / 3600))); $min = sprintf("%02d", (int ((($runtime - ($hour * 3600)) / 60 +)))); $job->{'jobtime'} = "$hour:$min"; foreach $key (@keys) { print OUTPUT "$key = ${$job}{$key}\n" if (${$job}{$key} ne + ""); } print OUTPUT "\n---------------------------------------------- +----------\n\n"; } } print "==>".@jobs."\n"; close OUTPUT; sub getservers { my (@servers1, @servers2, @servers3); print "\nLooking up server names\n\n"; my $domain = Win32::DomainName; Win32::NetAdmin::GetDomainController("", $domain, $PDC) || print " +Unable to obtain the PDC name for $domain."; Win32::NetAdmin::GetServers($pdc, $domain, 0x00000008, \@servers1) + || print "Unable to read NetBios 0008."; Win32::NetAdmin::GetServers($pdc, $domain, 0x00000010, \@servers2) + || print "Unable to read NetBios 0010."; Win32::NetAdmin::GetServers($pdc, $domain, 0x00008000, \@servers3) + || print "Unable to read NetBios 8000."; @servers = (@servers1, @servers2, @servers3); }

In reply to Win32 Task Scheduler Monitor by LovelyGreeting

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-25 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found