MLUG: Re: [MLUG] basic Unix pipe/exit code problem
Re: [MLUG] basic Unix pipe/exit code problem
Email address obfuscation in effect -- please click here to turn it off.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Mark Rages wrote:

>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
>  
>
I'm not sure I understand your actual problem, but would && help?

Essentially, <command1> && <command2> = do command2 only if command1 
succeeds

-- 
death (
	life++;
	);

_______________________________________________
members mailing list
EMAIL:PROTECTED
http://mlug.missouri.edu/mailman/listinfo/members