Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #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\ servername\n\ttask 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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (4)
    As of 2018-06-20 01:03 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (116 votes). Check out past polls.