In windows 2000, catching error output is not obvious because you lose the error code returned by command, for example suppose I want to execute MYPROG from within a oorexx macro :
command = "MYPROG 2>&1 | RXQUEUE"
ADDRESS CMD command
do i = 1 to queued()
/ --- /
if MYPROG fails logically and returns a code, it will be lost by OOREXX, where RC value will always be = 0 (even if you get the output console)
This contrast with regina rexx
ADDRESS SYSTEM cmd WITH OUTPUT STEM rescmd. ERROR STEM errcmd.
where you get stderr in errcmd. stem, and the external program return code
As documentation is not very clear, does anyone has a solution ?
Since Rick has been answering most of these, I'll try to catch this one. (Unfortunately, Rick is usually quicker than I am. <grin>)
The problem here is that RXQUEUE is an executable program and it is the last to execute. So the return code is the code from RXQUEUE, not your MYPROG.
There is not much that can change that with the current ooRexx. The solution is to not use RXQUEUE.
If you don't need the output, then redirect to null. On Windows you do that with something like:
command = "MYPROG 1>nul 2>&1"
I usually don't use ADDRESS, but just pass the string to the outside environment.
When I need to capture the output for some reason, I redirect to a temp file, read the file, delete the file. Something like this:
command = "MYPROG > MyFileName.temp 2>&1"
realRC = RC
fsObj = .stream~new('MyFileName.temp')
output = fsObj~arrayin
say 'MYPROG returns:' realRC
say "It's output was:"
do line over output
Since I do that sort a thing quite often, I just wrote some public routines to handle the sequence. Once you do that it is pretty easy to use.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.