SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Exit code from command line

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Exit code from command line
Author Message
Eugene Volynsky



Joined: 09 Dec 2003
Posts: 3

Post Exit code from command line Reply with quote

Hello,

We are using 24x7 version 3.2.1.
Is there any way to get a return value( exit code)
of the job when it is executed from command line?

For Example:
24x7 /JOB 123

Thanks,
Eugene

Tue Dec 09, 2003 4:51 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7969

Post Re: Exit code from command line Reply with quote

There is no direct way to get this exit code. The most simple solution is to convert this job to a script type job (if it is not a script type).

In the script write the desired exit code to a work file or simply set some environment variable whose value you can check after the job run.

: Hello,

: We are using 24x7 version 3.2.1.
: Is there any way to get a return value( exit code)
: of the job when it is executed from command line?

: For Example: 24x7 /JOB 123

: Thanks,
: Eugene

Tue Dec 09, 2003 5:07 pm View user's profile Send private message
Eugene Volynsky



Joined: 09 Dec 2003
Posts: 3

Post Re: Exit code from command line Reply with quote

I have chacked 24x7 help and it is still not clear for me
how to set exit code. I have found only function
ProcessGetExitCode, but do not see any set exit code function.
Also if I use enviromental variable what command do you have
(I do not see something like 'shell' in 24x7 help).
If you could provide some example, it would be really helpfull.

Thanks,

Eugene

: There is no direct way to get this exit code. The most simple solution is to
: convert this job to a script type job (if it is not a script type).

: In the script write the desired exit code to a work file or simply set some
: environment variable whose value you can check after the job run.

Tue Dec 09, 2003 6:20 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7969

Post Re: Exit code from command line Reply with quote

Use Run, RunAndWait, RunAsUser, RunWithInput or similar command to execute external processes and operation system commands.

For example, create a batch file like the following

; set environment variable
SET %1=%2
; print current value
SET %1%
; pause
PAUSE

If you call this file as test.bat then from the script you can run it as
Dim process_id, number
RunAndWait "test.bat myvar exitcode", "", 0, process_id

Please note that the environment value is only valid for the duration of the job and the process that triggered that job.

: I have chacked 24x7 help and it is still not clear for me
: how to set exit code. I have found only function
: ProcessGetExitCode, but do not see any set exit code function.
: Also if I use enviromental variable what command do you have
: (I do not see something like 'shell' in 24x7 help).
: If you could provide some example, it would be really helpfull.

: Thanks,

: Eugene

Wed Dec 10, 2003 12:31 am View user's profile Send private message
Eugene Volynsky



Joined: 09 Dec 2003
Posts: 3

Post Re: Exit code from command line Reply with quote

I probably did poor job on explaining what I need.

So, we run 24x7 job from the batch file as a command:

SET something=...
...
"C:\Program Files\24x7 Automation 3\24X7.EXE " /JOB 238
...

and we need to check in this batch file if JOB succeed or failed.
So we need to check exitcode from 24x7
from OUTSIDE(!) of 24x7 .
Any suggestions?

Thank you.

: Use Run, RunAndWait, RunAsUser, RunWithInput or similar command to execute
: external processes and operation system commands.

: For example, create a batch file like the following

: ; set environment variable
: SET %1=%2
: ; print current value
: SET %1%
: ; pause
: PAUSE

: If you call this file as test.bat then from the script you can run it as
: Dim process_id, number
: RunAndWait "test.bat myvar exitcode", "", 0, process_id

: Please note that the environment value is only valid for the duration of the
: job and the process that triggered that job.

Thu Dec 11, 2003 11:09 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7969

Post Re: Exit code from command line Reply with quote

That's what the provided solution is for

You would need 2 batch files - one file you already have and use to run the job. Another file is to set the environment variable.

Here is an example

1. Job #238 script

// ...
// Do the actual job here
// ...
// Let's assume the value to be returned is stored
// in MY_EXIT_CODE script variable.

// Write temporary batch file to set DOS environment variable MY_ENV_VAR
Dim proc_id, number
Dim command, string
Concat "SET MY_ENV_VAR=", MY_EXIT_CODE, command
FileSave "temp.bat", command

2. Your main batch file

ECHO This is the main batch file
; run the job
24X7.EXE /JOB 238
; run the temp.bat which will set the environment variable
CALL temp.bat
; print the value
ECHO %MY_ENV_VAR%
; use it
IF MY_ENV_VAR==5 GOTO some label here

Of course this is just an example. Modify it to suite your needs.

: I probably did poor job on explaining what I need.

: So, we run 24x7 job from the batch file as a command: SET something=...
: ...
: "C:\Program Files\24x7 Automation 3\24X7.EXE " /JOB 238
: ...

: and we need to check in this batch file if JOB succeed or failed.
: So we need to check exitcode from 24x7
: from OUTSIDE(!) of 24x7 .
: Any suggestions?

: Thank you.

Thu Dec 11, 2003 12:52 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.