tag:blogger.com,1999:blog-1304632214644526142.post5846033860120500178..comments2023-05-12T12:29:59.923+08:00Comments on Scratching My Needs: Bash - How to check the exit status of pipe commandPsyberMonkeyhttp://www.blogger.com/profile/00048858509837732571noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-1304632214644526142.post-59840517423028590052012-06-29T00:02:26.259+08:002012-06-29T00:02:26.259+08:00The $PIPESTATUS variable is a great tip :)
There...The $PIPESTATUS variable is a great tip :) <br /><br />There's a small bug with the example though, once you access PIPESTATUS it gets overwritten:<br /><br />$ false<br />$ echo $PIPESTATUS[0]<br />1[0]<br />$ echo $PIPESTATUS[0]<br />0[0]<br /><br />This essentially means you'll always get "failed with error 0" in the event of a failure.<br /><br />Do it like this:<br /><br />brk3https://www.blogger.com/profile/15677432325358174959noreply@blogger.comtag:blogger.com,1999:blog-1304632214644526142.post-34180840256070112452012-01-18T14:02:09.126+08:002012-01-18T14:02:09.126+08:00Thank you so much!
I was scratching my head over t...Thank you so much!<br />I was scratching my head over the exit status of<br />netstat -ntap | grep sshd<br />in a bash script, to find if ssh service is running. And i would get exit status 0 evrytime even when ssh was down.Bijuhttps://www.blogger.com/profile/04787385177423832903noreply@blogger.com