<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BASH Cures Cancer &#187; Contests</title>
	<atom:link href="http://bashcurescancer.com/category/contests/feed" rel="self" type="application/rss+xml" />
	<link>http://bashcurescancer.com</link>
	<description>Learn the UNIX/Linux command line</description>
	<lastBuildDate>Tue, 25 Oct 2011 18:09:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Win a book by submitting a legitimate use for /bin/false</title>
		<link>http://bashcurescancer.com/win-a-book-by-submitting-a-legitimate-use-for-binfalse.html</link>
		<comments>http://bashcurescancer.com/win-a-book-by-submitting-a-legitimate-use-for-binfalse.html#comments</comments>
		<pubDate>Sun, 24 Feb 2008 22:09:09 +0000</pubDate>
		<dc:creator>Brock Noland</dc:creator>
				<category><![CDATA[Contests]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://bashcurescancer.com/win-a-book-by-submitting-a-legitimate-use-for-binfalse.html</guid>
		<description><![CDATA[The other day I came across Solaris&#8217;s implementation of /bin/true. I use &#8220;true&#8221; for infinite while loops quite often. However, I began to wonder what legitimate uses existed for &#8220;false&#8221;. Example: disabling shell access for user accounts. Do you know of another legitimate use of false? Submit an example by commenting on this post and [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://bashcurescancer.com/media/books/book-cover-shell-scripting-recipes.jpg" /></p>
<p>The other day I came across <a href="http://forums.thedailywtf.com/forums/t/3779.aspx">Solaris&#8217;s implementation of /bin/true</a>. I use &#8220;true&#8221; for infinite while loops quite often. However, I began to wonder what legitimate uses existed for &#8220;false&#8221;. Example: disabling shell access for user accounts. Do you know of another legitimate use of false? Submit an example by commenting on this post and win <a href="http://www.amazon.com/exec/obidos/ASIN/1590594711/cfajbooks-20/701-6022635-4198729" target="_blank">Chris F.A. Johnson’s Shell Scripting Recipes</a>.</p>
<p>Rules:</p>
<ol>
<li>&#8220;Disabling shell access for user accounts&#8221; is not a valid submission.</li>
<li>You cannot submit someone else&#8217;s submission.</li>
<li>One submission per person.</li>
<li>I will take submissions until March 9, 2008 10PM CST.</li>
<li>One winner will be randomly chosen from the valid submissions.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://bashcurescancer.com/win-a-book-by-submitting-a-legitimate-use-for-binfalse.html/feed</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Win a book by debugging this shell script</title>
		<link>http://bashcurescancer.com/win-a-book-by-debugging-this-shell-script.html</link>
		<comments>http://bashcurescancer.com/win-a-book-by-debugging-this-shell-script.html#comments</comments>
		<pubDate>Mon, 15 Oct 2007 14:00:02 +0000</pubDate>
		<dc:creator>Brock Noland</dc:creator>
				<category><![CDATA[Contests]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[set -x]]></category>
		<category><![CDATA[shell options]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://bashcurescancer.com/win-a-book-by-debugging-this-shell-script.html</guid>
		<description><![CDATA[  Win a copy of Chris F.A. Johnson&#8217;s Shell Scripting Recipes by telling me why the script below does not work. UPDATE: Quite a few people responded correctly (see comments).  I will sort it out tonight and decide who wins. #/bin/bash doRead() {   local retVal=1   ps -e -o user &#124; grep apache &#124; \ [...]]]></description>
			<content:encoded><![CDATA[<p><img border="0" width="240" src="http://bashcurescancer.com/media/books/book-cover-shell-scripting-recipes.jpg" height="240" /> </p>
<p>Win a copy of <a target="_blank" href="http://www.amazon.com/exec/obidos/ASIN/1590594711/cfajbooks-20/701-6022635-4198729">Chris F.A. Johnson&#8217;s Shell Scripting Recipes</a> by telling me why the script below does not work.</p>
<p><em>UPDATE: Quite a few people responded correctly (see comments).  I will sort it out tonight and decide who wins.</em></p>
<p><code>#/bin/bash<br />
doRead()<br />
{<br />
  local retVal=1<br />
  ps -e -o user | grep apache | \<br />
  while read user<br />
  do<br />
  echo $user<br />
  retVal=0<br />
  done<br />
  return $retVal<br />
}<br />
</code><code>doRead<br />
echo "doRead exited with retVal = $?"</code></p>
<p>When the script runs, assuming the host has a user named apache and is running something, you should see &#8220;apache&#8221; a few times and then &#8220;doRead exited with retVal = 0&#8243;. However, the actual output is below:</p>
<p><code># ./readReturnValExample.sh<br />
apache<br />
apache<br />
apache<br />
apache<br />
apache<br />
apache<br />
apache<br />
apache<br />
doRead exited with retVal = 1</code></p>
<p>I ran into this problem when writing the <a href="http://bashcurescancer.com/monitor-cpu-abusers-with-this-simple-script.html">monitor cpu usage shell script</a>.  I could have put echo statement&#8217;s all over the place in order to find out what the value of retVal is at various points in the script.  However, I used the shell&#8217;s builtin debug option instead. I just added &#8220;set -x&#8221; to the top of the script, like so:</p>
<p><code>#/bin/bash<br />
set -x<br />
doRead()</code></p>
<p>This prints out exactly what the shell is doing.</p>
<p><code># ./readReturnValExample.sh<br />
++ doRead<br />
++ local retVal=1<br />
++ ps -e -o user<br />
++ grep apache<br />
++ read user<br />
++ echo apache<br />
apache<br />
++ retVal=0<br />
++ read user<br />
++ echo apache<br />
apache<br />
++ retVal=0<br />
++ read user<br />
++ echo apache<br />
apache<br />
++ retVal=0<br />
++ read user<br />
++ echo apache<br />
apache<br />
++ retVal=0<br />
++ read user<br />
++ echo apache<br />
apache<br />
++ retVal=0<br />
++ read user<br />
++ echo apache<br />
apache<br />
++ retVal=0<br />
++ read user<br />
++ echo apache<br />
apache<br />
++ retVal=0<br />
++ read user<br />
++ echo apache<br />
apache<br />
++ retVal=0<br />
++ read user<br />
++ return 1<br />
++ echo 'doRead exited with retVal = 1'<br />
doRead exited with retVal = 1</code></p>
<p>As you can see, the value of $retVal is valued at 1, directly after the last and unsuccesful read statement. The $25.99 dollar question is, why? I remember reading something about this a long, long time ago but its quite hazy and a cursory google search did not resolve my question. The person that answers that question (<a href="http://bashcurescancer.com/improve-this-script-win-100-dollars.html">except Chris as he won my last contest</a>) gets the book. If multiple people answer, the best single answer gets the book.</p>
]]></content:encoded>
			<wfw:commentRss>http://bashcurescancer.com/win-a-book-by-debugging-this-shell-script.html/feed</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>Improve this Script and Win $100USD</title>
		<link>http://bashcurescancer.com/improve-this-script-win-100-dollars.html</link>
		<comments>http://bashcurescancer.com/improve-this-script-win-100-dollars.html#comments</comments>
		<pubDate>Sat, 24 Feb 2007 13:50:28 +0000</pubDate>
		<dc:creator>Brock Noland</dc:creator>
				<category><![CDATA[Contests]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://bashcurescancer.com/improve-this-script-win-100-dollars.html</guid>
		<description><![CDATA[After publishing 10 Linux commands you&#8217;ve never used I was the benefactor of much feedback as to how I could have used the commands better. Which is great, I certainly do not have all the answers and I love to see the way others do things. To that end I offering $100USD to the best [...]]]></description>
			<content:encoded><![CDATA[<p>After publishing <a href="http://bashcurescancer.com/10-linux-commands-youve-never-used.html">10 Linux commands you&#8217;ve never used</a> I was the benefactor of much feedback as to how I could have used the commands better. Which is great, I certainly do not have all the answers and I love to see the way others do things.</p>
<p>To that end I offering $100USD to the best improvement to this script, <a href="http://bashcurescancer.com/media/scripting_comp_02242007/httpClient.sh.txt">httpClient.sh</a>. I have always wanted a pure BASH http client and thus I put this together last night. Its not perfect, some things are screaming to be fixed. In addition some other features should be added.</p>
<p>The rules:</p>
<ol>
<li>Your work MUST be original.</li>
<li>Your work MUST be derived from the script above.</li>
<li>It CAN NOT use netcat (nc).</li>
<li>It MUST be submitted to me via email to this address: <img src="http://spamdefeator.com/u/5d0" alt="SpamDefeator" border="0" height="15" width="180" />.</li>
<li>The script must contain, as comments, your name, email, and website (if you have one).</li>
<li>It MUST be submitted by March 7th at midnight CST.</li>
<li>Also NOTE that BASH must be compiled with networking support to use the script. I believe most distributions do this, Debian apparently does not.</li>
</ol>
<p>I will judge based on the following in no particular order. There is no need to fix them all, the winner may just fix one, in a really cool way:</p>
<ul>
<li>I would like to see it <a href="http://bashcurescancer.com/exit_status.html">exit with an error status</a> when the server responds with an error.<br />
Meaningful exit status?</li>
<li>Handling white space better.</li>
<li>Storing the headers in an array.</li>
<li>Following the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">HTTP 1.1 RFC</a> more. (HEAD with meaningful exit codes?)</li>
<li>Adding an option to save headers to a file.</li>
<li>Sometimes 0 is printed after the HTML, not sure why.</li>
<li>f19 is printed before the HTML when grabbing google, not sure why.</li>
<li>User agent</li>
<li>I had to institute a timeout on read otherwise it took 3-5 seconds to timeout. I&#8217;d like this handled better.</li>
<li>I am not sure what happens when you download binary data or large files.</li>
<li>Better ways of handling things, novel practices, clean code, and of course my opinion.</li>
</ul>
<p><span style="font-weight: bold; font-size: 125%">Chris FA Johnson won with this version of <a href="http://bashcurescancer.com/media/scripting_comp_02242007/ChrisFAJohnsonHttpClient.sh.txt">httpClient.sh</a>! Congratulations Chris! </span></p>
]]></content:encoded>
			<wfw:commentRss>http://bashcurescancer.com/improve-this-script-win-100-dollars.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.218 seconds -->

