Avanti Product Banner

avanti's TaskMaster ®
TaskMaster Lite (TMLite)
Task (.TSK) Tips
(Last Updated: 10 December 2004)

When the TaskMaster Master NLM is loaded on a Server, it adds a more powerful batch processing engine (.NCF/.TSK) and integrates a task scheduler. These features allow TaskMaster to not only replace but exceed the capabilities and features found in Novell's 'officially unsupported' CRON (scheduler) utility.

Task (.TSK) Tips
DIR Custom Reports: Use the options available in DIR to create custom File System reports
IF EXIST for Remote DIR / VOL: Test to confirm the existence of a Directory or Volume on a Remote Server
Subroutines in a .TSK: Implementing subroutines (GOSUB/RETURN) within a task script
Overlapping Tasks: Avoid concurrent execution of a task; Suspend a task until another task completes.

Additional Information/Support Links
Enhanced Processor: TaskMaster / TMLite Quick Reference: Enhanced Batch Processor
Extended Commands: TaskMaster / TMLite Quick Reference: Extended Console Commands
Sample Tasks: Examples of TaskMaster task script logic.

General FAQ: Frequently Asked Questions (FAQs) about avanti's products.
SYNC FAQ: Frequently Asked Questions (FAQs) about TaskMaster's SYNC command.
TaskMaster FAQ Frequently Asked Questions (FAQs) about TaskMaster.




DIR CUSTOM REPORTS:

Using the options supported by the DIR extended Local Console Command, it is possible to collect and output highly selective information about the File System contents. The following examples will demonstrate how the options supported by DIR can be combined to produce a slective report:

Note: DIR supports output redirection (>vol:path\filename.ext) to send the output displayed on the Server Console screen to a file.

List all entries in the SYS:SYSTEM directory:

DIR SYS:SYSTEM

List only those entries matching a specific pattern (*.NLM):

DIR SYS:SYSTEM\*.NLM

Change the pattern to a generic wild card (*.*), change the starting point to the root of the SYS Volume (SYS:), and recurse (/S - search) all directories in the directory tree beneath the starting point:

DIR SYS:*.* /S         Note: Searches the entire SYS: Volume.

Change the output to only provide bare information (/B - vol:path\filename.ext only, no entry information) for entries in the SYS Volume:

DIR SYS:*.* /B /S

Limit the bare output to entries in the SYS Volume with the Hidden attribute set (/A=H):

DIR SYS:*.* /A=H /B /S         Note: Multiple /A option can be combined (i.e., /A=H /A=RO ...).

Limit the bare output to entries in the SYS Volume without the Read Only attribute set (/A=-RO):

DIR SYS:*.* /A=-RO /B /S         Note: Multiple /A option can be combined (i.e., /A=-H /A=-RO ...).

Limit the bare output to entries in the SYS Volume which are Files (/-D = exclude Directories):

DIR SYS:*.* /B /-D /S

Limit the bare output to entries in the SYS Volume which are Directories (/-F = exclude Files):

DIR SYS:*.* /B /-F /S

Limit the bare output to entries in the SYS Volume Owned by Admin.ctx (/O=Admin.ctx):

DIR SYS:*.* /B /O=Admin.ctx /S         Note: /O= cannot be used with /-O.

Limit the bare output to entries in the SYS Volume without a valid Owner ID assigned (/-O):

DIR SYS:*.* /B /-O /S         Note: /-O cannot be used with /O=.

Limit the bare output to entries in the SYS Volume with Admin.ctx assigned as a Trustee (/R=Admin.ctx):

DIR SYS:*.* /B /R=Admin.ctx /S         Note: /R= cannot be used with /-R.

Limit the bare output to entries in the SYS Volume with an invalid Trustee assigned (/-R):

DIR SYS:*.* /B /-R /S         Note: /-R cannot be used with /R=.

Limit the bare output to entries in the SYS Volume with a Size of 1 KB (/L=1024):

DIR SYS:*.* /B /L=1024 /S

Limit the bare output to entries in the SYS Volume with a Size of 1 MB or less (/L=-1048576):

DIR SYS:*.* /B /L=-1048576 /S

Limit the bare output to entries in the SYS Volume with a Size of 2 MB or more (/L=+2097152):

DIR SYS:*.* /B /L=+2097152 /S

Limit the bare output to entries in the SYS Volume with a Size between 1 MB and 2 MB (/L=1048576-2097152):

DIR SYS:*.* /B /L=1048576-2097152 /S

Limit the bare output to entries in the SYS Volume that were Created on 26 July 2004 (/T=C2004/07/26):

DIR SYS:*.* /B /S /T=C2004/07/26         Note: Last Accessed Date   /T=A...   |   Last Modified Date   /T=M...

Limit the bare output to entries in the SYS Volume that were Created on or before 26 July 2004 (/T=C-2004/07/26):

DIR SYS:*.* /B /S /T=C-2004/07/26         Note: Last Accessed Date   /T=A-...   |   Last Modified Date   /T=M-...

Limit the bare output to entries in the SYS Volume that were Created on or after 26 July 2004 (/T=C+2004/07/26):

DIR SYS:*.* /B /S /T=C+2004/07/26         Note: Last Accessed Date   /T=A+...   |   Last Modified Date   /T=M+...

Limit the bare output to entries in the SYS Volume that were Created between 21 - 26 July 2004 (/T=C2004/07/21-2004/07/26):

DIR SYS:*.* /B /S /T=C2004/07/21-2004/07/26         Note: Last Accessed Date   /T=A...   |   Last Modified Date   /T=M...


Combined Custom Report Examples:
Note: While multiple /A options can be specified, the /L /O /R /T options are limited to using one of each at a time (i.e., the different options can be combined but only one form of each option can be used).

Produce a normal listing of only Files with a .MPG extension in or below the SYS:HOME base directory that are 2 MB or larger:

DIR SYS:HOME\*.MPG /-D /L=+2097152 /S

Produce a normal listing of all new File System entries in the SYS Volume Created on 27 July 2004:

DIR SYS:*.* /T=C2004/07/27 /S

Produce a bare output listing of all *.NLM Files in the SYS:SYSTEM directory without a valid Owner assigment:

DIR SYS:SYSTEM\*.NLM /B /-D /-O         Note: Unless /S is specified, the listing contains only the file names, not the vol:path.

Produce a bare output listing of all entries in the SYS Volume Owned by Admin.ctx Created between 01 - 31 July 2004 of a Size of 1 MB or larger:

DIR SYS:*.* /B /L=+1048576 /O=Admin.ctx /S /T=C2004/07/01-2004/07/31



IF EXIST for Remote DIR / VOL:

While the IF EXIST conditional test does not support Remote Servers directly in the current release, the following technique can be used to test for the existence of a Directory or Volume on a Remote Server:

TMSCMD [RemoteServer] CHDIR [vol:path]
IF ERRORLEVEL
    ECHO [RemoteServer/vol:Path] does not exist!
ELSE
    ECHO [RemoteServer/vol:Path] is a valid directory!
ENDIF

In the TMSCMD command line, [RemoteServer] should be replaced with the name of the Remote Server on which the DIR / VOL resides (e.g., AVANTI_510 instead of [RemoteServer]). The Directory to be checked ([vol:path) needs to be specified in NetWare format (e.g., SYS:SYSTEM) and relative to the Remote Server (i.e., the Remote Server name is not required in this specification). To check for the existence of a Volume, check for the Root Directory of the Volume (i.e., SYS:\).

In the example above, the results are displayed to the screen using the ECHO command. Substitute the appropriate commands for success or failure in place of the ECHO commands.

In the following example, the logic will check for the existence of the SYS:SYSTEM directory on the Server FSBACKUP and EXIT (i.e., terminate the task) if not found:

TMSCMD FSBACKUP CHDIR SYS:SYSTEM
IF ERRORLEVEL THEN EXIT

In the following example, the logic will check for the existence of the DATA:APPS directory on the Server FSBACKUP. If the directory does not exist, the TMSCMD command is used to send the MKDIR DATA:APPS command to the Remote Server FSBACKUP to create the directory. If the directory exists, the TMSCMD command is used to send the DELTREE DATA:APPS\*.* command to the Remote Server FSBACKUP to clear (empty) the directory.

TMSCMD FSBACKUP CHDIR DATA:APPS
IF ERRORLEVEL
    TMSCMD FSBACKUP MKDIR DATA:APPS
ELSE
    TMSCMD FSBACKUP DELTREE DATA:APPS\*.*
ENDIF



SUBROUTINES IN A .TSK:

There are occassions within task logic where it would be convenient to be able to transfer processing to (GOTO) a different part of the task script, yet be able to return back after executing the special commands. Some versions of BASIC and scripting languages provide such capabilities via CALL or GOSUB commands. TaskMaster's scripting language does not currently support GOSUB and implements the CALL command similar to DOS batch processing (i.e., suspend processing of the current task until a separate task script, specified by the CALL command, completes processing). However, due to TaskMaster's dynamic variable support, it is possible to implement the GOSUB functionality in the current release.

The following example searches a specific set of subdirectories for a specific set of filenames / extensions:

      //====================================================================
      // Uses four of the dynamic System Environment Variables (%0-%9)
      // %0  Index to first/next label to retrieve subdirectory list
      // %1  Used to retrieve/check each item in the subdirectory list
      // %2  Index to first/next label to retrieve filename/extension list
      // %3  Used to retrieve/check each item in the filename/extension list
      //--------------------------------------------------------------------

      // Setup up subdirectory label index counter for initial use

      DEFINE %0 00


      WHILE

          // Increment subdirectory label index counter then
          // GOTO the matching label to retrieve the first/next subdirectory

          DEFINE %0 %0+=01
          GOTO GET-SUB-%0


          // Return label for GOTO GET-SUB-%0 processing

          :PROC-SUB


          // Check if returned subdirectory (%1) is NULL (i.e., no more)

          IF "%1"=="" THEN BREAK


          // Set Current Working Directory (CWD) to the retrieved subdirectory

          CD %1


          // Setup up filename/extension label index counter for initial use

          DEFINE %2 00


          WHILE

              // Increment subdirectory label index counter then
              // GOTO the matching label to retrieve the first/next filename/ext

              DEFINE %2 %2+=01
              GOTO GET-FILE-%2


              // Return label for GOTO GET-FILE-%0 processing

              :PROC-FILE


              // Check if returned filename/ext (%1) is NULL (i.e., no more)

              IF "%3"=="" THEN BREAK


              // Check if filename/extension exists and process accordingly

              IF EXIST %3

                  // Process matching file in specified subdirectory

              ENDIF

          LOOP

      LOOP


      // Finished processing all filenames/extensions for each subdirectory

      EXIT


      // The individual labels which each DEFINE a different subdirectory

      :GET-SUB-01
      DEFINE %1 SYS:PUBLIC
      GOTO PROC-SUB

      :GET-SUB-02
      DEFINE %1 SYS:SYSTEM
      GOTO PROC-SUB

      // No more subdirectories need processing so return a NULL value

      :GET-SUB-03
      DEFINE %1
      GOTO PROC-SUB



      // The individual labels which each DEFINE a different subdirectory

      :GET-FILE-01
      DEFINE %3 *.BAK
      GOTO PROC-FILE

      :GET-FILE-02
      DEFINE %3 *.TMP
      GOTO PROC-FILE

      :GET-FILE-03
      DEFINE %3 INFECTED.EXE
      GOTO PROC-FILE

      // No more subdirectories need processing so return a NULL value

      :GET-FILE-04
      DEFINE %3
      GOTO PROC-FILE

      //====================================================================
      


OVERLAPPING TASKS:

TaskMaster supports concurrent and multiple task execution by providing each task with its own Current Working Directory (CWD) and stack. Depending upon the task schedule and the operations performed within the task, it is possible for a scheduled task to begin execution prior to the completion of a previous iteration of the same task. There are also situations where it can be important to assure the completion of a separate task prior to execution of the current task.

Avoid Concurrent Execution of a Task:
Logic can be added to a task to insure that the same task does not execute if a previous iteration of the task, or a separate task, is active.

Suspend A Task Until Another Task Completes:
Logic can be added to a task to insure that the task does not execute until a previous iteration of the task or a separate task completes.
  • The following tests if the specified task is executing and puts the current task to SLEEP until the first task completes (rechecking every 15 seconds and remaining in the WHILE/LOOP until the first occurrence of the task completes):

              WHILE ACTIVE_TASK [PREVTASK.TSK]
                SLEEP 15
              LOOP
              

    Note: The name of the appropriate task should be substituted for the bracketed ([]) PREVTASK.TSK task name (exclude the brackets). The name of the current task can be automatically assumed via the %TASK% System Environment Variable to suspend concurrent execution of the same task.

  • The following assumes the output of a command within the specified task has been redirected to a log file (using the optional output redirection) and puts the current task to SLEEP until the file is no longer in use (rechecking every 15 seconds and remaining in the WHILE/LOOP until the file is closed):

              WHILE FILE_IN_USE [SYS:SYNC.LOG]
                SLEEP 15
              LOOP
              

    Note: The name of the appropriate output redirection file should be substituted for the bracketed ([]) SYS:SYNC.LOG file name (excluding the brackets).