exit value (MORE INFO)

Mark Sicignano mark at hsi86.hsi.com
Thu Nov 15 14:00:05 AEST 1990


In article <1990Nov14.100834 at cs.utwente.nl> stadt at cs.utwente.nl (Richard van de Stadt) writes:
...
>       break ;;
>    *) # a new floppy
>       dkformat -m /vol/new_name >/dev/null 2>&1 &   #no output on screen
>       sleep 10 # be sure process is started
>                # actually done by looping on pid
>       attent /dev/dk1   # give what dkformat is waiting for
>       wait     # wait for format process to have finished
>       exitval='exit_value_of_last_process_started_in_background' ;;
>  esac
...

read the man page on sh(1)... particularly the "wait" command.
Wouldn't this work?

dkformat -m /vol/new_name > /dev/null 2>&1 &
sleep 10
attent /dev/dk1
wait $!
exitval=$?

wait will wait for a particular process id, if one is given,
and will return the exit status of the process id.  $! is the 
pid of the last command ran in the background.  

In other words, the wait will wait for your dkformat to exit
and will return the status, which you can get from $?.

You had all of the pieces to the puzzle yourself, just didn't
put them together right.  Have fun!

-mark
-- 
Mark Sicignano                                  ...!uunet!hsi!mark
3M Health Information Systems                   mark at hsi.com



More information about the Comp.unix.shell mailing list