<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Stupid Unix Trick &#8211; Command Mashups</title>
	<atom:link href="http://www.webadminblog.com/index.php/2010/01/08/stupid-unix-trick-command-mashups/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webadminblog.com/index.php/2010/01/08/stupid-unix-trick-command-mashups/</link>
	<description>Real Web Admins.  Real World Experience.</description>
	<lastBuildDate>Thu, 22 Jul 2010 22:44:25 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Alex Honor</title>
		<link>http://www.webadminblog.com/index.php/2010/01/08/stupid-unix-trick-command-mashups/comment-page-1/#comment-557</link>
		<dc:creator>Alex Honor</dc:creator>
		<pubDate>Sat, 30 Jan 2010 20:38:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.webadminblog.com/?p=362#comment-557</guid>
		<description>Relying on non-zero-exit  is such a great idiom and its consistent use will add up to more reliable and predictable outcomes. It&#039;s especially important when one script relies on calls to another.

Along with the &quot;&amp;&amp;&quot; (and) expression, I also like to use the the &quot;OR&quot; expression to manage error cases. For example this usage:

statement1 &#124;&#124; or-statement

This will cause the &quot;or-statement&quot; to run if the &quot;statement1&quot; command fails (ie, exits non-zero).

One can combine the &quot;OR&quot; and &quot;AND&quot; expressions with code blocks for a short hand if/then/else syntax


statement1 &amp;&#124;&#124; {
else-statement1; else-statement2
}


Here&#039;s a concrete example that checks if an error string is found in a log file

grep ERROR /path/to/log &amp;&#124;&#124; {
echo &quot;error found on `hostname`:/path/log/log&#124;mail -s &quot;error detected&quot; 
exit 1
}</description>
		<content:encoded><![CDATA[<p>Relying on non-zero-exit  is such a great idiom and its consistent use will add up to more reliable and predictable outcomes. It&#8217;s especially important when one script relies on calls to another.</p>
<p>Along with the &#8220;&amp;&amp;&#8221; (and) expression, I also like to use the the &#8220;OR&#8221; expression to manage error cases. For example this usage:</p>
<p>statement1 || or-statement</p>
<p>This will cause the &#8220;or-statement&#8221; to run if the &#8220;statement1&#8243; command fails (ie, exits non-zero).</p>
<p>One can combine the &#8220;OR&#8221; and &#8220;AND&#8221; expressions with code blocks for a short hand if/then/else syntax</p>
<p>statement1 &amp;|| {<br />
else-statement1; else-statement2<br />
}</p>
<p>Here&#8217;s a concrete example that checks if an error string is found in a log file</p>
<p>grep ERROR /path/to/log &amp;|| {<br />
echo &#8220;error found on `hostname`:/path/log/log|mail -s &#8220;error detected&#8221;<br />
exit 1<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>
