Can one be sure this trap is run DIRECTLY after a command ?

Can one be sure this trap is run DIRECTLY after a command ?

Post by Per Sabelstr » Thu, 12 Jun 1997 04:00:00



I have to propagate a value from a command to a
environment variable.
Here is a sketch of how to do this, but I think
there is one problem. (I found this neat idea in
this newsgroup)

I run a series of commands in a script.
I implement the commands I need myself, so
I can do what I will in them.

In the command (mycommand) I write a value (fcode) to
a file.
Then I send some signal, say 8 to PPID (the script)

In the shell I have made this:
trap "read file & set env. variable fcode" 8

Then the idea is to use fcode like this:

#! /usr/bin/ksh

..
..
mycommand params1
case $fcode in
  123)
..
..
  124)
..
..
mycommand params2
case $fcode in
  12)
..
  13)

Can one be sure that the signal has been caught and
dealt whith when one comes to case $fcode.
If not, is there some way to achive this (preferrably
in such a way that you dont have to do some stuff
between mycommand and case) ????

Pelle

 
 
 

Can one be sure this trap is run DIRECTLY after a command ?

Post by Allen Kirb » Sat, 14 Jun 1997 04:00:00



<snip>
> Then the idea is to use fcode like this:

> #! /usr/bin/ksh

> ..
> ..
> mycommand params1
> case $fcode in
>   123)
> ..
> ..
>   124)
> ..
> ..
> mycommand params2
> case $fcode in
>   12)
> ..
>   13)

<snip>
Why on earth (or anywhere else) would you want to do this?  Either
set the exit value of mycommand to fcode, and let the shell script
get it with $? (this does have limited values, i.e. 0-255 on most
systems).  Or, worst case, just write it on stdout and execute it like
this:

FCODE=`mycommand params1`
if [ $? -eq 0 ]
then
        case $FCODE in
.....

Only if the two methods above don't work would I do something different,
and then I wouldn't use signals.  Just go get the code out of the file
after mycommand completes with the appropriate exit value.
--
Allen Kirby                     AT&T ITS Production Services


 
 
 

Can one be sure this trap is run DIRECTLY after a command ?

Post by Per Sabelstr » Sat, 14 Jun 1997 04:00:00




><snip>
>Why on earth (or anywhere else) would you want to do this?  Either
>set the exit value of mycommand to fcode, and let the shell script
>get it with $? (this does have limited values, i.e. 0-255 on most
>systems).  Or, worst case, just write it on stdout and execute it like
>this:

>Only if the two methods above don't work would I do something different,
>and then I wouldn't use signals.

Thanks for your time.
Method 1 doesnt work because I need more then 8 bits (and negative numbers)
Method 2 doesnt work because it gets to messy to write script,
(the mechanism to get the value is primarily beeing used by others, and
its much easier to test $fcode or $?, but as I sad $? is to
small)
It should work with ksh93 (info from this group) to trap CHLD, in wich
case no signaling would be necesarry from mycommand) BUT we dont
have ksh93 on the system (tandem nonstop unix)
That only leaves me with the proposed method (I think), so the
questions remain: can one be sure that the TRAP '...' 8 is executed
BEFORE the next line ?

Pelle

 
 
 

1. I am with the following error, when i am running lilo...

Hi,
       I could't understand whats going wrong.
I compiled new kernel with kgdb patch..and entered the details in /etc/lilo.conf
and running lilo..

i got the following lines..

Warning: /etc/lilo.conf should be writable only for root ( I am in root login only)
Warning: device 0x0306 exceeds 1024 cylinder limit.

geo_comp_addr: Cylinder number is too big (  1146 > 1023).

Could any one help me out...

thanks,
srinivas.

2. Unable to Open Webpages remotely

3. I am in text mode, what browser am I running....

4. 2.2.2 an important release?

5. This clone thing...am I stupid, or am I right?

6. Restricting remote access.

7. PLEASE HELP - At Least Read This ONE!!!!

8. command to find out what OS i am running

9. Am I touchy? Or am I right?

10. Am I seeing IPv5, or am I hallucinating?

11. I am buying an Ultra 5 but am lost in part numbers ....

12. I am si**y am I?