SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Catching Errors from Programs

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Catching Errors from Programs
Author Message
Tim Cheng



Joined: 26 Feb 2004
Posts: 23

Post Catching Errors from Programs Reply with quote

Hi, im trying to execute a program and a specific file using the commandline in RunandWait
I want to catch the error from this command.

I'm currently using getLastError. This works for getting errors that come up in the command line
Eg. The name of the executable is wrong or cannot be found.
however, once the executable filename is right the program opens up and if the parameter (filename) is wrong
it wouldnt be detected until the program opens up and opens up its own error message "file not found" and the getLastError function
would return nothing.

What i want to do is try and catch the error that is outputed by the program, rather than the command line.
Is this possible in JAL?

Thanks.

Tue Apr 20, 2004 7:20 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Re: Catching Errors from Programs Reply with quote

Yes, it is possible as long as your program reports the error using a specific exit code or prints an error message to the log or simply prints it to the console. If it is a Windows program that simply popups the message box then you will have hard time evaluationg for this condition (BTW, this is also doable)

To search a log file for errors use FileSearchEx, to get the program exit code use ProcessGetExitCode, to get the console output saved in a log file run your program as
myprogram.exe parameters here > mylog.log
then search the log file for errors.

: Hi, im trying to execute a program and a specific file using the commandline
: in RunandWait
: I want to catch the error from this command.

: I'm currently using getLastError. This works for getting errors that come up
: in the command line
: Eg. The name of the executable is wrong or cannot be found.
: however, once the executable filename is right the program opens up and if
: the parameter (filename) is wrong
: it wouldnt be detected until the program opens up and opens up its own error
: message "file not found" and the getLastError function
: would return nothing.

: What i want to do is try and catch the error that is outputed by the program,
: rather than the command line.
: Is this possible in JAL?

: Thanks.

Tue Apr 20, 2004 8:07 pm View user's profile Send private message
Tim Cheng



Joined: 26 Feb 2004
Posts: 23

Post Re: Catching Errors from Programs Reply with quote

"If it is a Windows program that simply popups the message box then you will have hard time evaluationg for this condition (BTW, this is also doable)"

Hi, could you please explain how this can be done?

Thu Jun 03, 2004 8:46 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Re: Catching Errors from Programs Reply with quote

Instead of using RunAndWait you can use Run
and then check in a loop if the started program is still running and if yes, if it displays an error message with specific title (and optionaly with a specific text).
If the program is not running then the job is done. If the error message is found then kill the process and handle the error.

Here is a sample script

/////////////////////////////////////////
Dim process_id, number
Dim process_running, boolean, True
Dim error_window, number

Run "myprogram.exe", "", process_id
LoopWhile process_running, END_LOOP
Wait 5
WindowFind "Error message title", error_window
IfThen error_window, HANDLE_ERROR

IsTaskRunning "myprogram.exe", process_running
END_LOOP:
Exit

HANDLE_ERROR:
... here goes code to handle this error ...
ProcessKill process_id

/////////////////////////////////////////

FYI: Available ProcessXXX and WindowsXXX statements can be used for monitoring and controlling virtually any graphical program. However to implement a reliable job you may need to code a lot of checks, such as to check if you have only instance of the program running at any given time; that the found error message belongs to the right instance and right program; etc…

: "If it is a Windows program that simply popups the message box then you
: will have hard time evaluationg for this condition (BTW, this is also
: doable)"

: Hi, could you please explain how this can be done?

Thu Jun 03, 2004 10:49 pm View user's profile Send private message
Tim Cheng



Joined: 26 Feb 2004
Posts: 23

Post Re: Catching Errors from Programs Reply with quote

Thanks for that. I'll give it a go.

Is there a way to catch a runtime error if the program that is running, doesnt output a windows dialog box?

: Instead of using RunAndWait you can use Run
: and then check in a loop if the started program is still running and if yes,
: if it displays an error message with specific title (and optionaly with a
: specific text).
: If the program is not running then the job is done. If the error message is
: found then kill the process and handle the error.

: Here is a sample script

: /////////////////////////////////////////
: Dim process_id, number
: Dim process_running, boolean, True
: Dim error_window, number

: Run "myprogram.exe", "", process_id
: LoopWhile process_running, END_LOOP
: Wait 5
: WindowFind "Error message title", error_window
: IfThen error_window, HANDLE_ERROR

: IsTaskRunning "myprogram.exe", process_running
: END_LOOP: Exit

: HANDLE_ERROR: ... here goes code to handle this error ...
: ProcessKill process_id

: /////////////////////////////////////////

: FYI: Available ProcessXXX and WindowsXXX statements can be used for
: monitoring and controlling virtually any graphical program. However to
: implement a reliable job you may need to code a lot of checks, such as to
: check if you have only instance of the program running at any given time;
: that the found error message belongs to the right instance and right
: program; etc…

Thu Jun 03, 2004 11:33 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Re: Catching Errors from Programs Reply with quote

ProcessGetExitCode. Please see on-line help for details.

: Thanks for that. I'll give it a go.

: Is there a way to catch a runtime error if the program that is running,
: doesnt output a windows dialog box?

Fri Jun 04, 2004 12:59 am View user's profile Send private message
Tim Cheng



Joined: 26 Feb 2004
Posts: 23

Post Re: Catching Errors from Programs Reply with quote

: ProcessGetExitCode. Please see on-line help for details.

doesnt work for me. im using:

Run "runmac32.exe D:\CognosData\Cubepoint\Macro\buildreport.mac d:\cognosdata\cubepoint\impromptu\CubePointTest.imr,D:\CognosData\CubePoint\Impromptu\cubepointtest5.cat,D:\CognosData\CubePoint\Impromptu\cubepointexcel.xls", "D:\\Program Files\\Cognos\\cer3\\bin\\", process_id
ProcessGetExitCode errorcode

errorcode ends up with 0, even thhough the program is throwing an exception.

the code: WindowFind "BUILD%", error_window

returns a 6 digit number.. rather than the text in the exception dialog box.

Fri Jun 04, 2004 1:14 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7955

Post Re: Catching Errors from Programs Reply with quote

Please read the help. It doesn't make sense to call ProcessGetExitCode immediately after Run. It makes sense to call it after RunAndWait. WindowFind returns window handle not window title. This is correct behavior. If you get a non-zero code it mean WindowFind found the searched window and retruend its handle. This handle can be used to close the window, or active it, or get text or get controls and their text, and so on... Again please read the help.

: doesnt work for me. im using: Run "runmac32.exe
: D:\CognosData\Cubepoint\Macro\buildreport.mac
: d:\cognosdata\cubepoint\impromptu\CubePointTest.imr,D:\CognosData\CubePoint\Impromptu\cubepointtest5.cat,D:\CognosData\CubePoint\Impromptu\cubepointexcel.xls",
: "D:\\Program Files\\Cognos\\cer3\\bin\\", process_id
: ProcessGetExitCode errorcode

: errorcode ends up with 0, even thhough the program is throwing an exception.

: the code: WindowFind "BUILD%", error_window

: returns a 6 digit number.. rather than the text in the exception dialog box.

Fri Jun 04, 2004 1:31 am 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.