HELP:Trapping return values

HELP:Trapping return values

Post by A Selv » Tue, 29 Apr 1997 04:00:00



I'm trying to trap return values from my executables (C programs) using
csh. I've found that "trap" in sh only traps hardware signals, I'd like
to do a similar thing except that I'd like to trap return values.

I've also tried set variable=`program` but this only traps printf
statements.  Any help would be appreciated.

-Selvan

 
 
 

HELP:Trapping return values

Post by Bill Marc » Tue, 29 Apr 1997 04:00:00



>I'm trying to trap return values from my executables (C programs) using
>csh. I've found that "trap" in sh only traps hardware signals, I'd like
>to do a similar thing except that I'd like to trap return values.

>I've also tried set variable=`program` but this only traps printf
>statements.  Any help would be appreciated.

>-Selvan

In csh
set variable=$status

In most other shells
variable=$?

--
Bill Marcum    bmarcum at iglou dot com
If gnus are outlawed, only outlaws will have gnus.

 
 
 

1. ksh: if I trap on exit to rm tmp files, how do I save return value ?

Hi !

I have the following (sample) script:

------------------------------------------
#!/bin/ksh

echo hi >/tmp/hi

trap "if [ -s /tmp/hi ];then rm /tmp/hi;exit; fi" 0 1 2 3

exit 1
------------------------------------------

Well, this script returns 0, while I want it to return 1.  It seems
that $? becomes 0 when "rm" succeeds.  ???

                                                        -- Mike Ratner

--
*****************************************************************************
Michael B. Ratner  Associate Programmer, Advanced Network & Services (ANS)

"The Road goes ever on and on..."  - J.R.R. Tolkien

2. Why 2 PIDs on rlogins?

3. can return values be trapped in a makefile

4. E4500 can not boot but all dev is ok ,MY GOD!!???

5. can makefile trap the return values

6. Can not telnet from unix to NT3.51

7. Default return value for when return() is not explicitly used on SC5.0

8. Looking for sources of CDE actions, etc. for Solaris CDE 1.2

9. return a value from oracle to unix shell help please

10. Assigning return value from a previous command[help]

11. Returning Values to a Unix Script - Please HELP !!!!

12. help returning a value on a line...

13. [Domingo: HELP: SEMOP RETURN VALUE]