#112625 - 2004-01-27 06:37 PM
New Scheduled Task Control Library for JT.EXE
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
|
When I wrote my original tsControl library, I wanted to allow the user to define the array names. The intent was that several event array pairs could be used within an application. After developing several complex scripts around this library, I realized that I had yet to require multiple simultaneous task definitions. Recent attempts at larger projects with EXPLICIT declarations prevented the "passing by reference" of the arrays.
This new version of tcLib is leaner, more robust, and above all, easier to use. It fully supports the Explicit and NoVarsInStrings options. The only limitation it imposes is that only one pair of event arrays is supported, and the names of these arrays are fixed - $a_tcTASK and $a_tcTRIG. It is NOT backward compatible with tsControl, however.
As before, the arrays can be defined using mnemonics, making the most common tasks easy to implement. Only a handful of parameters are needed for all but the most complex task definitions. The arrays can also be manipulated directly by regular kix commands.
Creating a task requires just four function calls:
tcInit()
tcDefineTask("args")
tcDefineTrigger("args")
tsSetEvent("host", "Task Name")
For applications that will manipulate the arrays directly, the Define function calls can be replaced with your own code.
In addition to these basic functions, others exist to obtain a list of events on a target system (tcGetTasks), delete triggers or entire events (tcDelTrigger or tcDelEvent). There are even a pair of functions to determine if a particular task or trigger exists (tcIsTask & tcIsTrigger).
EXAMPLES:
Define a scheduled task on a server. This task will run every 2 days between the end of Jan and end of Dec, 2004. The command is C:\scripts\greeneggs.bat, and uses arguments of "Seuss Fish(blue,red)". The task is run using my local
account and password.
Code:
; Define and initialize TASK and TRIG arrays
tcInit()
; Load TASK array with parameters
; can use one long or several short calls to tcDefineTask
; APPlication and PaRaMeters
tcDefineTask("APP=C:\scripts\GreenEggs.bat PRM=Seuss Fish(blue,red)")
; WorK Directory, and ComMenT
tcDefineTask("WKD=C:\temp CMT=Glenn's test code")
; USeR account and PassWorD
tcDefineTask("USR=gbarnas PWD=PassWord")
; Load TRIG array with parameters - every 2 days, starting 1/31, ending 12/31 of 2004
; StartDaTe, StartTiMe, EndDaTe, HasEndDate flag
tcDefineTrigger(0, "SDT=01/31/2004 STM=21:30 EDT=12/31/2004 HED=1")
; TYPe is daily, ARGument to TYPe is every 2 days
tcDefineTrigger(0, "TYP=daily ARG=2")
; create the event on the target system
; If the event already exists, it will be modified instead of created.
tcSetEvent('server', 'test event')
The task is now defined in the array and can be deployed to many systems by
simply calling tsSetEvent() in a loop, processing many server names.
Code:
For Each $Server in $AllServers
tcSetEvent($Server, 'test event')
Next
MORE ADVANCED EXAMPLES:
Code:
; Get a list of all tasks
$Tasks = tcGetTasks('server')
; Change account/password for all tasks where USR is "jsmith"
For Each $Task in $Tasks
tcInit(1) ; prep arrays with nulls
tcGetEvent('server', $Task)
If InStr($a_tcTASK[20], 'jsmith')
tcSetEventCredentials('server', $Task, 'newuser', 'WordpasS')
EndIf
Next
Here is the library UDF code:
New Task Control Library for JT.EXE
_________________________
Actually I am a Rocket Scientist!
|
|
Top
|
|
|
|
#112632 - 2004-01-28 11:24 PM
Re: New Scheduled Task Control Library for JT.EXE
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11628
Loc: CA
|
Glenn,
Do you have these 2 entries in your PostPrep code?
Code:
$txtSource.MaxLength = 0 $txtTarget.MaxLength = 0
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 1003 anonymous users online.
|
|
|