Return codes in script

Return codes in script

Post by Jan Klaverstij » Fri, 13 Sep 2002 17:46:01



I have a daemon and a script (3rd party) that are being used to integrate
applications on NT and AIX. The daemon on aix listens to requests from the
nt environment and executes arbitrary commands, in this case mentioned
script. The daemon is commercial software; I have no control over its
internals. Now the weirdest thing happens.

Consider the following snippet from my script:

wsetemsg $1 $2
rc=$?
...
exit $rc

If I run this script from the shell it works as expected, but when run by
the daemon $? (and thus $rc) is always zero. I tried other variations, like

wsetemsg && rc=1 || rc=0

but sofar no luck. Again, all's well when running from the shell but when
run from the daemon I always get succes, even when wsetemsg fails. I tested
with other commands than wsetemsg with the same results.

This is stumping me and I hope someone wil be able to help. I am game for
both workarounds and structural solutions. What we are trying to achieve is
a better guarding of this integration. As man failures as possible should be
notified.

Regards,
- Jan.

Detail: this concerns integration between Tivoli/Enterprise Console 3.6 and
Tivoli Service Desk 6.0.

 
 
 

Return codes in script

Post by Nicholas Drone » Fri, 13 Sep 2002 23:20:15



> I have a daemon and a script (3rd party) that are being used to integrate
> applications on NT and AIX. The daemon on aix listens to requests from the
> nt environment and executes arbitrary commands, in this case mentioned
> script. The daemon is commercial software; I have no control over its
> internals. Now the weirdest thing happens.
> Consider the following snippet from my script:
> wsetemsg $1 $2
> rc=$?
> ...
> exit $rc
> If I run this script from the shell it works as expected, but when run by
> the daemon $? (and thus $rc) is always zero. I tried other variations, like
> wsetemsg && rc=1 || rc=0

If wsetemsg expects a controlling terminal, it will never
succeed when running as a daemon.  (By "daemon," of course,
I assume you mean "started by init or at or cron.")

Regards,

Nicholas

 
 
 

Return codes in script

Post by Jan Klaverstij » Sat, 14 Sep 2002 16:14:33





> > I have a daemon and a script (3rd party) that are being used to
integrate
> > applications on NT and AIX. The daemon on aix listens to requests from
the
> > nt environment and executes arbitrary commands, in this case mentioned
> > script. The daemon is commercial software; I have no control over its
> > internals. Now the weirdest thing happens.

> > Consider the following snippet from my script:

> > wsetemsg $1 $2
> > rc=$?
> > ...
> > exit $rc

> > If I run this script from the shell it works as expected, but when run
by
> > the daemon $? (and thus $rc) is always zero. I tried other variations,
like

> > wsetemsg && rc=1 || rc=0

> If wsetemsg expects a controlling terminal, it will never
> succeed when running as a daemon.  (By "daemon," of course,
> I assume you mean "started by init or at or cron.")

It is not specific for wsetemsg. As mentioned I tried other commands. To be
more specific: the commands work well under normal circumstances, even
wsetemsg that by the way doesn't need a terminal. It's just that I want to
act upon errors, but $? is always zero no matter what. So if I test with ls
instead of wsetemsg the results are similar. The daemon is a little program
called nsmqueryd that listens to a port and executes commands requested by
clients connecting over the network.

- Show quoted text -

Quote:

> Regards,

> Nicholas

 
 
 

1. Interactive Scripts, return codes

Interactive scripts in Unix.
Return codes from Oracle, or Unix.  

I want to run a script in Unix,
that will call
1)      Oracle sqlplus
2)      Oracle sqlloader
3)      Oracle sqlplus.
exit

At certain points in the script,
I want to ask the user different
questions, and accept Yes or No responses.
How can I accomplish this, or,
what is the command to do this?

The other thing that I want to do,
is to check the return codes from
Oracle, and abort if the commands
failed.  How can this be accomplished?
How could I branch to another part of
the script?
Would the return code be from Unix,
or from Oracle?

Sorry for such basic questions,
I am rather new to these subjects.

Thanks in Advance,

Rodger Lepinsky
ADP Systems Partnership
Winnipeg, Manitoba, Canada

2. How could i make delay

3. How do i capture the return code in a expect script

4. best sound card

5. Help: Returning a return code to a program

6. Help needed on X server configuration

7. zonet pcmcia card not recognized

8. Returning an exit code with the PID as an exit code

9. Return Code or Error Code with patches

10. help: preserving error return codes thru function codes

11. Code fragments/plug-ins for solaris?

12. returning control back to my script after spawning another script