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

Re: Win32 Task Scheduler Monitor

by Courage (Parson)
on May 31, 2002 at 16:32 UTC ( #170759=note: print w/ replies, xml ) Need Help??


in reply to Win32 Task Scheduler Monitor

two obvious things:
- use Win32::AdminMisc; #and not win32::adminmisc; remember, that package names are case sensitive! Otherwise you'll face unexpected behaviour, such as not-calling 'import' package function at proper time.
- use strict; # will have a chance to see report about above mentioned problems

(I did similar things about a year ago, and will try to look deeper into your problem if my obvious advices will not work.)

Courage, the Cowardly Dog.


Comment on Re: Win32 Task Scheduler Monitor
Re: Win32 Task Scheduler Monitor
by Anonymous Monk on Jun 03, 2002 at 02:30 UTC
    Thank you, Courage. Attached modified code, it still got 0 task list back. And here is my configuration information for your reference:
    OS:Win2000 Professional Perl:ActiveState 5.005_02 Win32::AdminMisc:NAME="Win32-AdminMisc",VERSION="0,2000,07,08"
    use strict; use Win32::AdminMisc; my $server="\\\\twjimmywang"; my %JobInfo; my $Day; my @DOM; my %Jobs; my $Number; if (Win32::AdminMisc::ScheduleGet($server, 3, \%JobInfo)){ foreach $Day (1..31){ push(@DOM, $Day) if ($JobInfo{DOM} & 2**$Day); } print "This job will run on the following days of the month:\n"; print join(", ", @DOM); } print "==>".%JobInfo."\n"; Win32::AdminMisc::ScheduleList($server, \%Jobs); print "==>".%Jobs."\n"; foreach $Number (keys(%Jobs)){ print "Job $Number is $Jobs{$Number}->{Command}\n"; }
      well, my luck here is probably better that yours, because your latest unmodified script works with some non-zero results, after I added a task. Look:
      D:\>at 20:20 /interactive /every:5 calc Added a new job with job ID = 2 D:\Personal\perl\admin\tst>perl -w am.pl ==>0 ==>1/8 Job 2 is calc
      1/8 is hash in scalar context, you ignore "8" and see that you have one single key in that hash.

      Slightly reorganize code and see that we've got what we searched for:

      use strict; use Win32::AdminMisc; my $server="\\\\serverserversevverv"; my %JobInfo; my $Day; my @DOM; my %Jobs; my $Number; Win32::AdminMisc::ScheduleList($server, \%Jobs); print "==>".%Jobs."\n"; foreach $Number (keys(%Jobs)){ print "Job $Number is $Jobs{$Number}->{Command}\n"; if (Win32::AdminMisc::ScheduleGet($server, $Number, \%JobInfo)){ foreach $Day (1..31){ push(@DOM, $Day) if ($JobInfo{DOM} & 2**$Day); } print "This job will run on the following days of the month:\n +"; print join(", ", @DOM); } }
      the output is not that bad in my case:
      D:\Personal\perl\admin\tst>perl -w am.pl ==>2/8 Job 2 is calc This job will run on the following days of the month: 4Job 3 is calc This job will run on the following days of the month: 4, 18

      let me know if you need more details.

      Courage, the Cowardly Dog.
      PS. Something fishy is going on there, or my name is Vadim Konovalov. And it's not.

        Yes, Courage. You make it so clear. I can get the same result as yours, and I also know the difference between us. I did the schedule through Task Scheduler (Setting->Control Pannel->Scheduled Tasks, which Win2000 called Task Scheduler). Task scheduler has more control but can't be checked by AdminMisc::ScheduleGet. I have to set user account for scheduled task, but AT command doesn't support account setting. Any idea or suggestion?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://170759]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (13)
As of 2014-07-24 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (160 votes), past polls