Page 1 of 1 1
Topic Options
#112625 - 2004-01-27 06:37 PM New Scheduled Task Control Library for JT.EXE
Glenn Barnas Administrator Offline
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! \:D

Top
#112626 - 2004-01-27 10:53 PM Re: New Scheduled Task Control Library for JT.EXE
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Very nice Glenn....
_________________________
Co


Top
#112627 - 2004-01-27 11:13 PM Re: New Scheduled Task Control Library for JT.EXE
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yeah, but the library post in the UDF is cut off, thus there's no complete code.
_________________________
There are two types of vessels, submarines and targets.

Top
#112628 - 2004-01-28 03:15 AM Re: New Scheduled Task Control Library for JT.EXE
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
Dang! Again!!!

I previewed it when I posted it and it was all there.

_________________________
Actually I am a Rocket Scientist! \:D

Top
#112629 - 2004-01-28 03:57 PM Re: New Scheduled Task Control Library for JT.EXE
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Might be a length limit with regards to how long a post can be.Or it gets confused with that much HTML code. Maybe a KIX2UBB translator might be the better option.
_________________________
There are two types of vessels, submarines and targets.

Top
#112630 - 2004-01-28 06:01 PM Re: New Scheduled Task Control Library for JT.EXE
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
OK - that's what I'm thinking, too. The HTM is 101K, and what's being returned when I edit the post it 56K.

I'll delete the post and try it again in two parts.

I may be able to translate Kix2HTM to Kix2UBB over the next day or so.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#112631 - 2004-01-28 10:28 PM Re: New Scheduled Task Control Library for JT.EXE
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
OK - the complete library is now posted in THREE parts (one thread).

This is only a 37K script - what am I going to do when I post my System Inquisition Tool (SIT), which is currently 196K with comments (and still over 90K without)?

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#112632 - 2004-01-28 11:24 PM Re: New Scheduled Task Control Library for JT.EXE
NTDOC Administrator Offline
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
#112633 - 2004-01-29 12:45 AM Re: New Scheduled Task Control Library for JT.EXE
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4401
Loc: New Jersey
PostPrep 1.0.3.2 - those entries do not exist.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#112634 - 2004-01-29 01:00 AM Re: New Scheduled Task Control Library for JT.EXE
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11628
Loc: CA
$txtSource = $frm.TextBox(,3,5)
$txtSource.Right = $frm.ClientWidth-110
$txtSource.Bottom = $frm.ClientHeight/2-3
$txtSource.ScrollBars = 3
$txtSource.AcceptsTab = 1
$txtSource.FontName = "Courier New"
$txtSource.FontSize = 8
$txtSource.MultiLine = 1
$txtSource.Anchor = 1+2+4+8
$txtSource.MaxLength = 0
$txtSource.OnChange = "TextSource_Change()"

$txtTarget = $frm.TextBox(,3,5 + $txtSource.Bottom)
$txtTarget.Right = $frm.ClientWidth - 110
$txtTarget.Bottom = $frm.ClientHeight - 20
$txtTarget.ScrollBars = 3
$txtTarget.FontName = "Courier New"
$txtTarget.FontSize = 8
$txtTarget.MultiLine = 1
$txtTarget.MaxLength = 0
$txtTarget.Anchor = 2+4+8

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 1188 anonymous users online.
Newest Members
StuTheCoder, M_Moore, BeeEm, min_seow, Audio
17884 Registered Users

Generated in 0.063 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org