SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Returning Exit Codes

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Returning Exit Codes
Author Message
Greig



Joined: 15 Mar 2001
Posts: 49

Post Returning Exit Codes Reply with quote

I have a process that I would like to run as a Program Type Job. I understand how to set up the job to check for Exit Codes and generate a semaphore file if there is a non-successful exit code. However, is there any way for me to pass the actual exit code to another process using the semaphore file. For example, can I write the exit code to the file, or use the exit code in part of the semaphore's filename?

The problem I am trying to solve is that different actions are required depending on what value the exit code is.

Thanks
Greig

Thu Jun 20, 2002 11:18 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: Returning Exit Codes Reply with quote

To have some "if" or "case" logic you have to create a script type job. This is really simple.

Example job script:

Dim my_process, number
Dim exit_code, number

RunAndWait "my_program.bat", "", 0, my_process
ProcessGetExitCode exit_code

ChooseCase exit_code, END
Case 0
// success, nothing to do
Case 1
// error #1, send me email
MailSend .....
Case 2
// error #2, run fix it batch
Run "fix_it.bat", "", my_process
Case 3
// error #3, run fix it job
JobRun "Fix It Job"
CaseElse
// unknown error, log it and email me
LoggAddMessageEx "ERROR", @V"job_id", "@V"job_name"", "Unknown error detected"
END:

: I have a process that I would like to run as a Program Type Job. I understand
: how to set up the job to check for Exit Codes and generate a semaphore
: file if there is a non-successful exit code. However, is there any way for
: me to pass the actual exit code to another process using the semaphore
: file. For example, can I write the exit code to the file, or use the exit
: code in part of the semaphore's filename?

: The problem I am trying to solve is that different actions are required
: depending on what value the exit code is.

: Thanks
: Greig

Thu Jun 20, 2002 11:33 am View user's profile Send private message
Greig



Joined: 15 Mar 2001
Posts: 49

Post Re: Returning Exit Codes Reply with quote

Thanks for the quick response. Your code is how we process things at the moment. But we would really like to run the job as type Program and have another JAL script that executes it and checks the exit code. The reason for this is that we have lots of these jobs, and Dos Boxes pop up all the time, making it difficult to use the server when these are running since the focus keeps moving. Running a program type job allows me to hide the window. Perhaps as a future enhancement you could allow RunAndWait jobs to be hidden?

: To have some "if" or "case" logic you have to create a
: script type job. This is really simple.

: Example job script: Dim my_process, number
: Dim exit_code, number

: RunAndWait "my_program.bat", "", 0, my_process
: ProcessGetExitCode exit_code

: ChooseCase exit_code, END
: Case 0
: // success, nothing to do
: Case 1
: // error #1, send me email
: MailSend .....
: Case 2
: // error #2, run fix it batch
: Run "fix_it.bat", "", my_process
: Case 3
: // error #3, run fix it job
: JobRun "Fix It Job"
: CaseElse
: // unknown error, log it and email me
: LoggAddMessageEx "ERROR", @V"job_id",
: "@V"job_name"", "Unknown error detected"
: END:

Thu Jun 20, 2002 11:46 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7948

Post Re: Returning Exit Codes Reply with quote

Here is the trick that can be used to run processes hidden even if they are started from a script.

Use 2 jobs: script job without schedule and another program type job with the schedule. The second job will run the script job hidden. All processes created by the script job will also run hidden. The program type job should have the command line like "24x7 /JOB ". The job should be also set to run synchronous and in a hidden window.

Another workaround is to check ERRORLEVEL variable directly in your batch files

if errorlevel == 1 goto ...
if errorlevel == 2 goto ...

: Thanks for the quick response. Your code is how we process things at the
: moment. But we would really like to run the job as type Program and have
: another JAL script that executes it and checks the exit code. The reason
: for this is that we have lots of these jobs, and Dos Boxes pop up all the
: time, making it difficult to use the server when these are running since
: the focus keeps moving. Running a program type job allows me to hide the
: window. Perhaps as a future enhancement you could allow RunAndWait jobs to
: be hidden?

Thu Jun 20, 2002 12:45 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.