Accessing "RETURN-CODE" through UNIX 
Author Message
 Accessing "RETURN-CODE" through UNIX

Hi,

Can I access the value set in the "RETURN-CODE" register, through Unix??.
If yes, PLEASE let me know how ....

Thanks and Regards,
M Shetty



Tue, 09 Mar 2004 11:49:13 GMT  
 Accessing "RETURN-CODE" through UNIX

Quote:

> Hi,

> Can I access the value set in the "RETURN-CODE" register, through Unix??.
> If yes, PLEASE let me know how ....

Yes, depending on the COBOL manufacturer you are using.

See in the Unix manual how you access a return status from a command.
something like "$%" I don't really remember now, and my Unix boxes are
down for the next two weeks.

Maybe "man sh" or whatever shell you are using will help you.

FF



Tue, 09 Mar 2004 19:35:28 GMT  
 Accessing "RETURN-CODE" through UNIX

Quote:
> Hi,

> Can I access the value set in the "RETURN-CODE" register, through Unix??.
> If yes, PLEASE let me know how ....

Didn't you specify yesterday that you wanted to access this through a
script?

I haven't worked on a unix system in about three years, so I'm rusty, but
isn't there an 'errorlevel' you can interrogate in a script? That's where
return-code should end up.

If you want to access it from a COBOL program - that is, you are CALLing a
program which sets return-code, that should be available to the CALLing
program using the CALL  ... USING ... RETURNING  syntax.

MCM



Tue, 09 Mar 2004 19:48:07 GMT  
 Accessing "RETURN-CODE" through UNIX
Quote:



> > Hi,

> > Can I access the value set in the "RETURN-CODE" register, through Unix??.
> > If yes, PLEASE let me know how ....

> Didn't you specify yesterday that you wanted to access this through a
> script?

I wanted to access it using a shell script in Unix.

Got another doubt...... If you can help me out. I managed to access
the "RETURN-CODE" register through Unix using a $?.

This is what I found please let me know if it is correct.
I was calling a COBOL sub-prog from a COBOL main prog. There was no
error handling done in the COBOL sub-prog. The sub-prog threw a
"DIVIDE-BY-ZERO" error. Checking the "RETURN-CODE" register through
Unix using a $? showed a number 134. Does this mean that the
"RETURN-CODE" was set by COBOL when the program aborted ?? Or is this
some random value ??

Thanks and Regards,
M Shetty



Wed, 10 Mar 2004 15:53:32 GMT  
 Accessing "RETURN-CODE" through UNIX
I think the setting of the RETURN-CODE register is done by both the
programmer and the compiler/run-time. When you call a subprogram, the
subprogram may set the return code. If you don't change that register, when
'main' ends it will return whatever was in there, however it got there.

What may be something for you to think about is interrogating RETURN-CODE
immeduately upon return from 'subprogram', as in..

PROGRAM-ID. MAIN.

...
     MOVE zero to RETURN-CODE
     CALL 'subprogram' using x
     IF RETURN-CODE NOT EQUAL ZERO
         DISPLAY 'Subprogram failed with return-code=' RETURN-CODE
     END-IF
    ...

MCM

--
Michael Mattias
Tal Systems Inc.
Racine WI USA



Quote:


> > > Hi,

> > > Can I access the value set in the "RETURN-CODE" register, through
Unix??.
> > > If yes, PLEASE let me know how ....

> > Didn't you specify yesterday that you wanted to access this through a
> > script?
> I wanted to access it using a shell script in Unix.

> Got another doubt...... If you can help me out. I managed to access
> the "RETURN-CODE" register through Unix using a $?.

> This is what I found please let me know if it is correct.
> I was calling a COBOL sub-prog from a COBOL main prog. There was no
> error handling done in the COBOL sub-prog. The sub-prog threw a
> "DIVIDE-BY-ZERO" error. Checking the "RETURN-CODE" register through
> Unix using a $? showed a number 134. Does this mean that the
> "RETURN-CODE" was set by COBOL when the program aborted ?? Or is this
> some random value ??

> Thanks and Regards,
> M Shetty



Wed, 10 Mar 2004 21:01:01 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Acessing "RETURN-CODE" register

2. weird "return -code" handling

3. Return Code from "exec"

4. coding "else return nothing", "else return blank space" ??

5. US - FL -****UNIX/UNIXFOCUS PROGRAMMER ("C", INGRESS,UNIX OS)****CONTRACT

6. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

7. A "return" statement within "bind" Tcl code generates a Tcl error dialog

8. Receiver of "return"

9. Return us "Cancel" button during compilation

10. GET without "Return"

11. history of "ignoring return value"

 

 
Powered by phpBB® Forum Software