SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Job failure error trapping

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Job failure error trapping
Author Message
Gary Jensen



Joined: 22 Mar 2000
Posts: 28

Post Job failure error trapping Reply with quote

We want to create custom emails that will tell us which external process within a job script timed out. Are there examples of trapping these error codes within JAL scripts so we can control what occurs, or are we stuck with the default processes that we setup when the job is created?

Currently:

Runandwait times out.
The program generates a generic email

What we want:
Runandwait times out.
Error code is trapped within the script.
Script sends specific email indicating which Runandwait command timed out.
Directory cleanup and process reset occurs.
Exit the program using the original error code we trapped above.

Tue May 09, 2000 12:37 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7840

Post Re: Job failure error trapping Reply with quote

Use the following method as one of the possible solutions to this situation

1. First, turn on "ignore errors" for that job

2. Create DOS bacth that runs the program then creates some file at the end
For example:
myprogram.exe
dir > c:\flag.txt

Therefore, if myprogram timesout then the flag file is not created

3. In the JAL script code
RunAndWait( "mybatch.bat", ...
FileExists( "c:\flag.txt", flag_found )
if( flag_found, DELETE_FLAG, ERROR_HANLER )
DELETE_FLAG:

FileDelete( "c:\flag.txt" )

Exit

ERROR_HANLER:

MailSend ....

: We want to create custom emails that will tell us which external process
: within a job script timed out. Are there examples of trapping these error
: codes within JAL scripts so we can control what occurs, or are we stuck
: with the default processes that we setup when the job is created?

: Currently: Runandwait times out.
: The program generates a generic email

: What we want: Runandwait times out.
: Error code is trapped within the script.
: Script sends specific email indicating which Runandwait command timed out.
: Directory cleanup and process reset occurs.
: Exit the program using the original error code we trapped above.

Tue May 09, 2000 1:58 pm View user's profile Send private message
Gary Jensen



Joined: 22 Mar 2000
Posts: 28

Post Re: Job failure error trapping Reply with quote

You can't be serious. I currently have a bunch of batch files doing stuff. The idea is to replace them, but not with a bunch of other batch files for error checking.
You mean to tell me that your program doesn't create an error we can trap (or test the value of) in a timeout state? I have to create files and test for the files just so I can tell where in a script a timeout has occurred?
This doesn't even include the number of CONCAT commands I will need to create some of the strings to execute the command lines for theses batch programs since they will need to be able to run the process that was on the original Runandwait command line.
Maybe someone could give me a call tomorrow at 360-586-4665 if this can't be addressed easily in a response.

: Use the following method as one of the possible solutions to this situation

: 1. First, turn on "ignore errors" for that job

: 2. Create DOS bacth that runs the program then creates some file at the end
: For example: myprogram.exe
: dir > c:\flag.txt

: Therefore, if myprogram timesout then the flag file is not created

: 3. In the JAL script code
: RunAndWait( "mybatch.bat", ...
: FileExists( "c:\flag.txt", flag_found )
: if( flag_found, DELETE_FLAG, ERROR_HANLER )
: DELETE_FLAG: FileDelete( "c:\flag.txt" )

: Exit

: ERROR_HANLER: MailSend ....

Wed May 10, 2000 4:37 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7840

Post Re: Job failure error trapping Reply with quote

You can wrap all this functionality in a single user-defined JAL statement that simulates RunAndWait then you will call your statement instead of RunAndWait.
This statement is not efficient as RunAndWait but can do the trick

One of the possible implementations for such statement is to run and monitor the process, do something like the following:

// this statement should have at least 2 arguments: command line and timeout
// it also should return some value to indicate success/failure
Dim process_id, number
Dim temp, number

Run , "", process_id
LoopWhile , END_LOOP

// wait one second

Wait 1

Subtract , 1,

// check whether the process is still running,

// if yes do another loop if it's not timed out

ProcessGetWindow process_id, temp

If temp, END_LOOP, FINISHED
END_LOOP:

// timeout, kill the process
ProcessKill process_id
Return "TIMEOUT"

FINISHED:
// process finished in time
return "FINISHED"

: You can't be serious. I currently have a bunch of batch files doing stuff.
: The idea is to replace them, but not with a bunch of other batch files for
: error checking.
: You mean to tell me that your program doesn't create an error we can trap (or
: test the value of) in a timeout state? I have to create files and test for
: the files just so I can tell where in a script a timeout has occurred?
: This doesn't even include the number of CONCAT commands I will need to create
: some of the strings to execute the command lines for theses batch programs
: since they will need to be able to run the process that was on the
: original Runandwait command line.
: Maybe someone could give me a call tomorrow at 360-586-4665 if this can't be
: addressed easily in a response.

Wed May 10, 2000 5:13 pm View user's profile Send private message
Ken Wyatt



Joined: 11 May 2000
Posts: 4

Post Re: Job failure error trapping Reply with quote

There is some missing links here. I have gone over the manual thoroughly and cannot find anything on how to insert an argument into a user-defined JAL statement. In your example below you have JAL statements that are not complete. Is this how you get an argument into the statement?

Statement - [Run,"",process_id] is missing a parameter - could that be argument 1? If so how does the statement know which argument to use where?

Statement - [LoopWhile,END_LOOP] is missing a parameter - could that be argument 2? If so how does the statement know which parameter is missing and which argument to use?

Statement - [Subtract,1,] is missing 2 parameters. If it is using the timeout argument, how does it know which argument to use? Both arguments have already been used.

: You can wrap all this functionality in a single user-defined JAL statement
: that simulates RunAndWait then you will call your statement instead of
: RunAndWait.
: This statement is not efficient as RunAndWait but can do the trick

: One of the possible implementations for such statement is to run and monitor
: the process, do something like the following: // this statement should
: have at least 2 arguments: command line and timeout
: // it also should return some value to indicate success/failure
: Dim process_id, number
: Dim temp, number

: Run , "", process_id
: LoopWhile , END_LOOP

: // wait one second

: Wait 1

: Subtract , 1,

: // check whether the process is still running,

: // if yes do another loop if it's not timed out

: ProcessGetWindow process_id, temp

: If temp, END_LOOP, FINISHED
: END_LOOP: // timeout, kill the process
: ProcessKill process_id
: Return "TIMEOUT"

: FINISHED: // process finished in time
: return "FINISHED"

Thu May 11, 2000 12:29 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7840

Post Re: Job failure error trapping Reply with quote

I was talking about a user-defined JAL statement (see Tools/Script Library menu then click New button)
When you define a new JAL statement you have an option to specify statement parameters and statement return type. In the code for that statement you can reference statement parameters by name just like if they were declared as local or global variables

For example: create new statement "RunMyProgram" having 2 parameters
"ProgramName" and "Argument" of "string" datatypes. Specify "number" for the statement return type. For the statement code enter

// declare local variables
Dim ProcessID, number
Dim CommandLine, string

// Build command line: add one space and argument to the end of program name
Concat ProgramName, " ", CommandLine
Concat CommandLine, Argument, CommandLine

// run program passed as a parameter to this statement
Run CommandLine, "", ProcessID

// return process id to the calling script (so it can
// kill the process if required
Return ProcessID

Note that in user-defined statements parameters are used by their names and not by order in which they were specified in the statement definition, where in built-in JAL statements parameters are evaluated by order. This is standard for most programming languages.

: There is some missing links here. I have gone over the manual thoroughly and
: cannot find anything on how to insert an argument into a user-defined JAL
: statement. In your example below you have JAL statements that are not
: complete. Is this how you get an argument into the statement?

: Statement - [Run,"",process_id] is missing a parameter - could that
: be argument 1? If so how does the statement know which argument to use
: where?

: Statement - [LoopWhile,END_LOOP] is missing a parameter - could that be
: argument 2? If so how does the statement know which parameter is missing
: and which argument to use?

: Statement - [Subtract,1,] is missing 2 parameters. If it is using the timeout
: argument, how does it know which argument to use? Both arguments have
: already been used.

Thu May 11, 2000 1:56 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7840

Post Re: Job failure error trapping Reply with quote

use ProcessGetExitCode in v2.2.0 and later

: We want to create custom emails that will tell us which external process
: within a job script timed out. Are there examples of trapping these error
: codes within JAL scripts so we can control what occurs, or are we stuck
: with the default processes that we setup when the job is created?

: Currently: Runandwait times out.
: The program generates a generic email

: What we want: Runandwait times out.
: Error code is trapped within the script.
: Script sends specific email indicating which Runandwait command timed out.
: Directory cleanup and process reset occurs.
: Exit the program using the original error code we trapped above.

Wed May 24, 2000 3:15 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.