![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's | manas6 | UNIX for Dummies Questions & Answers | 0 | 06-05-2008 06:44 AM |
| code that reads commands from the standard i/p and executes the commands | Phrozen Smoke | High Level Programming | 4 | 01-22-2007 02:06 AM |
| Checking Return Codes of Background Processes | bergerj3 | Shell Programming and Scripting | 2 | 11-14-2003 03:15 PM |
| pipe help | bb666 | High Level Programming | 5 | 02-26-2002 04:07 PM |
| return codes from rsh commands... | bbouch | UNIX for Dummies Questions & Answers | 1 | 02-20-2002 07:03 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Checking return value of commands in pipe
Hi,
I am wondering how I can check the return value of all commands in a pipe such as gzip -dc file.gz | sort -u > output.txt If I run this sequence in bash and check $?, I get the return status from sort. But I want to know if the initial gzip failed. Similarly for longer pipe chains, I want to know if any of the components returned an error status. I don't mind if you give a solution for another shell such as tcsh. Any solution is great! Thanks! |
|
||||
|
But how does one do it in a shell that doesn't have PIPESTATUS? I know that autoconf (tool to install source on almost Unix that has lots of shell-independent logic in it) plays tricks with redirection and subshells to capture the return values from inner pipe commands. I just never took the time to reverse engineer it in my head to understand it.
Anyone? |
|
||||
|
PIPESTATUS and autoconfigure
At the risk of sounding like a hermit (talking to myself), I recently examined some of the configure scripts and saw several patterns:
So the PIPESTATUS appears to be unique in the ability to extract return values from simple pipe commands. Quote:
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|