Email address obfuscation in effect -- please
click here to turn it off.
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
- To: MLUG Members <EMAIL:PROTECTED>
- Subject: Re: [MLUG] basic Unix pipe/exit code problem
- From: Mark Rages <EMAIL:PROTECTED>
- Date: Thu, 3 Mar 2005 14:05:52 -0600
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws;s=beta; d=gmail.com;h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references;b=pecJEHiycutXIqTjIchUGI/ZW1G8iTiC06zSbnjf+oZ5Y/MhPZ2NXlA2KTe6kR0e0lBUhA5ODPqw3JZYFGlGBVCaCbPYuUX2a6yPPmpxdaVYiNw1cNO4Qt1kmmWLpoZRlfvK3skYbJh84Wpj+JUOa9FpzKLmUqsRsjTU7eSCX0s=
- In-reply-to: <EMAIL:PROTECTED>
- References: <EMAIL:PROTECTED> <EMAIL:PROTECTED> <EMAIL:PROTECTED>
- Reply-to: Mark Rages <EMAIL:PROTECTED>, MLUG Members<EMAIL:PROTECTED>
- Sender: EMAIL:PROTECTED
Ok, so here's one solution from some Perl guys:
http://use.perl.org/~cog/journal/18948
yuck. does everybody do their shell scripts this way?
Regards,
Mark
EMAIL:PROTECTED
On Thu, 3 Mar 2005 13:08:02 -0600, Mark Rages <EMAIL:PROTECTED> wrote:
> On Thu, 3 Mar 2005 12:54:35 -0600 (CST), Mike Miller
> <EMAIL:PROTECTED> wrote:
> > On Thu, 3 Mar 2005, Mark Rages wrote:
> >
> > > I have reduced my problem to this:
> > >
> > > ( /bin/false | gzip > /dev/null ) || echo fail
> > >
> > > I want it to echo "fail" because /bin/false gives a nonzero exit code.
> > > But it doesn't. What am I missing?
> >
> > Maybe I'm not understanding this. If you are gzipping from stdin, don't
> > you need to do it this way:
> >
> > | gzip -c - >
> >
> > Maybe that isn't your intention. I'm not sure how gzip is used in a path
> > when it isn't reading stdin and writing to stdout.
> >
> > I don't quite understand 'false'. Where is the exit code detected? It
> > doesn't go to stderr or to stdout.
>
> A little more explanation, then.
>
> Unix programs return a numeric code to the shell when they finish.
> This code is 0 when the program finishes successfully, and an error
> code when the program fails.
>
> /bin/false exits immediately with a nonzero exit code. ( /bin/true
> exits with 0 )
>
> I was using /bin/false only as an example of a failing command. I was
> trying to explain my situation where I'm executing a string of
> commands piped together, and I want to know if one of the commands
> failed or not. (this is a script for making backups, so I can't just
> let it silently fail!)
>
> What I thought (appears to be wrong) is that if a command at the
> beginning of a pipe fails, it will send SIGPIPE to the next command,
> which will kill it with an error, and so on, until the shell will
> receive an error code. This is obviously incorrect. Can some Unix
> guru explain this to me?
>
> Regards,
> Mark
> EMAIL:PROTECTED
> --
> You think that it is a secret, but it never has been one.
> - fortune cookie
>
--
You think that it is a secret, but it never has been one.
- fortune cookie
_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members