getting status from a subshell command in a pipe-line

getting status from a subshell command in a pipe-line

Post by Steven D. Majews » Thu, 25 Mar 1993 07:04:58



I was just doing something like (in ksh) :

   ( dd if=/dev/rmt0.1 count=10; status=$? ) | tar -tvf - | head  -8

in a script, and was trying to figure out why $status never
changed ( and thus why it never left the loop. ).

Once I actually read what I was writing ( :-> ) I figured out
the problem.

I guess I have to do something like:

   ( dd if=/dev/rmt0.1 ; echo $? 1>.dd.status ) | tar -tvf - | head -8
   read status <.dd.status

Which seems to work.

But is there a less convoluted way to get the status from
the first command in the pipeline?


- Univ. of *ia - Department of Molecular Physiology and Biological Physics

 
 
 

getting status from a subshell command in a pipe-line

Post by Paul Haa » Thu, 25 Mar 1993 09:45:09




Quote:> But is there a less convoluted way to get the status from
> the first command in the pipeline?

use rc, which returns as the exit status of a pipe a list of
all the exit statuses of the commands in the pipeline.

--
paul haahr              adobe systems incorporated


 
 
 

1. getting status from first command in a piped command line

Hi everyone,

I am facing a little problem while doing a script.
I am using pipe "|" between 2 commands :
tar cvf - /directory | gzip > backup.file.gz

my concern is getting any error status from the tar
command, as the exist status of gzip is of no use
to know if things went well.

Is there any way for me to get $? from the 1st
command ?

any comment or workaround would be appreciated.
(I would avoid using an intermediate file).

thanks in avance,

Ahmed RAHAL.

2. linux,sc,and /dev/hdc1

3. Getting Exit Status from subshell and pipe

4. sounds with lemacs

5. exit status of the command in pipe from shell & named pipe

6. Gnome 0.30 problem (libc5 and libc6)

7. getting status from cmd in pipe

8. Font Problem

9. Difficulty retrieving exit status of command before pipe

10. Get exit status of first command in pipe.

11. pipe but still grab command status

12. bash: catch status of command before piping

13. Obtaining the exit code (status) of command piped to tee