<?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: Bash User Input Validation</title>
	<atom:link href="http://savvyadmin.com/bash-user-input-validation/feed/" rel="self" type="application/rss+xml" />
	<link>http://savvyadmin.com/bash-user-input-validation/</link>
	<description>For savvy admins everywhere...</description>
	<lastBuildDate>Sat, 04 Feb 2012 22:20:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<item>
		<title>By: wayne</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-1015</link>
		<dc:creator>wayne</dc:creator>
		<pubDate>Wed, 28 Sep 2011 00:13:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-1015</guid>
		<description>looks like my regular expression was annihilated by your comment form. email me if you want it.</description>
		<content:encoded><![CDATA[<p>looks like my regular expression was annihilated by your comment form. email me if you want it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wayne</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-1014</link>
		<dc:creator>wayne</dc:creator>
		<pubDate>Wed, 28 Sep 2011 00:09:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-1014</guid>
		<description>if this is input validation, shouldn&#039;t it actually check for an appropriate input and inform the user if it is not correct? that is my understanding of what &quot;input validation&quot; means.  here is something i wrote up to check to see if a mac address is valid for a given company whose allocation starts with &quot;00:01:32&quot;:

tmp=$(echo $REPLY &#124; grep -E &quot;\&quot; \
		&#124; tr -d :)
if [ &quot;x$tmp&quot; == &quot;x&quot; ] ;then
	echo &quot;Please enter a valid Brawndo MAC Address.&quot;
	exit 1
fi

the very best thing about this is the smiley face at the end of the third line. just sayin...</description>
		<content:encoded><![CDATA[<p>if this is input validation, shouldn&#8217;t it actually check for an appropriate input and inform the user if it is not correct? that is my understanding of what &#8220;input validation&#8221; means.  here is something i wrote up to check to see if a mac address is valid for a given company whose allocation starts with &#8220;00:01:32&#8243;:</p>
<p>tmp=$(echo $REPLY | grep -E &#8220;\&#8221; \<br />
		| tr -d :)<br />
if [ "x$tmp" == "x" ] ;then<br />
	echo &#8220;Please enter a valid Brawndo MAC Address.&#8221;<br />
	exit 1<br />
fi</p>
<p>the very best thing about this is the smiley face at the end of the third line. just sayin&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Angie</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-1000</link>
		<dc:creator>Angie</dc:creator>
		<pubDate>Thu, 28 Apr 2011 01:58:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-1000</guid>
		<description>@buddyh

For Y/N use &#039;case&#039;. Check out scripts under /etc/init.d/ for proper use of &#039;case&#039;</description>
		<content:encoded><![CDATA[<p>@buddyh</p>
<p>For Y/N use &#8216;case&#8217;. Check out scripts under /etc/init.d/ for proper use of &#8216;case&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gmendoza</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-860</link>
		<dc:creator>gmendoza</dc:creator>
		<pubDate>Wed, 30 Dec 2009 09:48:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-860</guid>
		<description>@Pawan Jaitly:  Thanks for your input.  I&#039;ll add the Bash method as it certainly is the simplest method!</description>
		<content:encoded><![CDATA[<p>@Pawan Jaitly:  Thanks for your input.  I&#8217;ll add the Bash method as it certainly is the simplest method!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pawan Jaitly</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-575</link>
		<dc:creator>Pawan Jaitly</dc:creator>
		<pubDate>Tue, 03 Nov 2009 16:04:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-575</guid>
		<description>A bash way of doing this:

DIRTY=&quot;a dirty string&quot;
CLEAN=${DIRTY//[^a-zA-Z0-9]/}

In this example the dirty characters are spaces. Modify to taste.</description>
		<content:encoded><![CDATA[<p>A bash way of doing this:</p>
<p>DIRTY=&#8221;a dirty string&#8221;<br />
CLEAN=${DIRTY//[^a-zA-Z0-9]/}</p>
<p>In this example the dirty characters are spaces. Modify to taste.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gmendoza</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-365</link>
		<dc:creator>gmendoza</dc:creator>
		<pubDate>Thu, 25 Jun 2009 15:33:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-365</guid>
		<description>Apparently tr does not support multibyte characters (yet).  Found this post with comments that suggest support for UTF-8 and UTF-16 is coming.  See http://tinyurl.com/mqsb69 for more details.</description>
		<content:encoded><![CDATA[<p>Apparently tr does not support multibyte characters (yet).  Found this post with comments that suggest support for UTF-8 and UTF-16 is coming.  See <a href="http://tinyurl.com/mqsb69" rel="nofollow">http://tinyurl.com/mqsb69</a> for more details.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Avery</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-363</link>
		<dc:creator>Avery</dc:creator>
		<pubDate>Wed, 24 Jun 2009 06:43:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-363</guid>
		<description>any clues for using tr to also allow utf-8 characters - the alnum doesn&#039;t seem to okay things like...  ñáéíóúçäüö etc...</description>
		<content:encoded><![CDATA[<p>any clues for using tr to also allow utf-8 characters &#8211; the alnum doesn&#8217;t seem to okay things like&#8230;  ñáéíóúçäüö etc&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: buddyh</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-249</link>
		<dc:creator>buddyh</dc:creator>
		<pubDate>Tue, 21 Oct 2008 11:27:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-249</guid>
		<description>As a learning admin this is great info.  I thought there was a way to limit the input to a specific set of characters.  I just need to have the user input a Y or N in either upper or lower case and reject any other entry.  Thinking of using a while loop till a correct char is entered as an alternative.  
Tx in advance</description>
		<content:encoded><![CDATA[<p>As a learning admin this is great info.  I thought there was a way to limit the input to a specific set of characters.  I just need to have the user input a Y or N in either upper or lower case and reject any other entry.  Thinking of using a while loop till a correct char is entered as an alternative.<br />
Tx in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: al</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-246</link>
		<dc:creator>al</dc:creator>
		<pubDate>Thu, 16 Oct 2008 22:08:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-246</guid>
		<description>Thanks a bunch - I&#039;ll remember this one.</description>
		<content:encoded><![CDATA[<p>Thanks a bunch &#8211; I&#8217;ll remember this one.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gmendoza</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-245</link>
		<dc:creator>gmendoza</dc:creator>
		<pubDate>Thu, 16 Oct 2008 18:17:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-245</guid>
		<description>Easy... use sed to strip beginning and trailing spaces:

tr -cd &#039;[:alnum:] [:space:]&#039; &#124; sed -e &#039;s/^[ ]*//&#039; -e &#039;s/[ ]*$//&#039;</description>
		<content:encoded><![CDATA[<p>Easy&#8230; use sed to strip beginning and trailing spaces:</p>
<p>tr -cd &#8216;[:alnum:] [:space:]&#8216; | sed -e &#8216;s/^[ ]*//&#8217; -e &#8216;s/[ ]*$//&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: al</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-244</link>
		<dc:creator>al</dc:creator>
		<pubDate>Thu, 16 Oct 2008 14:18:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-244</guid>
		<description>I actually did that. But please consider following - someone puts in the username &quot;al_the_on___the_sea&quot;. I wouldn&#039;t want to shrink it to &quot;altheon&quot; after cutting 10 spaces, but would rather have &quot;al_the_on&quot; . This would make it 9 char, but if the last space was left &quot;al_the_on_&quot; it would be user difficult to use such a name. I tried different ways, but nothing easy came about. If you have some sort of solution, I would be all ears. Also from programming perspective, one would have to check from the back of the string moving forward until first alphanumeric character was found.</description>
		<content:encoded><![CDATA[<p>I actually did that. But please consider following &#8211; someone puts in the username &#8220;al_the_on___the_sea&#8221;. I wouldn&#8217;t want to shrink it to &#8220;altheon&#8221; after cutting 10 spaces, but would rather have &#8220;al_the_on&#8221; . This would make it 9 char, but if the last space was left &#8220;al_the_on_&#8221; it would be user difficult to use such a name. I tried different ways, but nothing easy came about. If you have some sort of solution, I would be all ears. Also from programming perspective, one would have to check from the back of the string moving forward until first alphanumeric character was found.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gmendoza</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-243</link>
		<dc:creator>gmendoza</dc:creator>
		<pubDate>Wed, 15 Oct 2008 19:55:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-243</guid>
		<description>Hi there.  The example in the post explains that alphanumeric and spaces are allowed.  Simply omit the [space] value, and you&#039;ll be left strictly with alphanumeric.  For example:

tr -cd &#039;[:alnum:]&#039;
</description>
		<content:encoded><![CDATA[<p>Hi there.  The example in the post explains that alphanumeric and spaces are allowed.  Simply omit the [space] value, and you&#8217;ll be left strictly with alphanumeric.  For example:</p>
<p>tr -cd &#8216;[:alnum:]&#8216;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: al</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-242</link>
		<dc:creator>al</dc:creator>
		<pubDate>Wed, 15 Oct 2008 19:49:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-242</guid>
		<description>I had something similar to complete not too long ago. I found it very hard to manipulate last characters going backwards in order to edit spaces. Example 10 character password al--------, where &quot;-&quot; is equal to space. In order to check for that and concatenate to just &quot;al&quot; instead of &quot;al          &quot; - what approach would you use?</description>
		<content:encoded><![CDATA[<p>I had something similar to complete not too long ago. I found it very hard to manipulate last characters going backwards in order to edit spaces. Example 10 character password al&#8212;&#8212;&#8211;, where &#8220;-&#8221; is equal to space. In order to check for that and concatenate to just &#8220;al&#8221; instead of &#8220;al          &#8221; &#8211; what approach would you use?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amarendra</title>
		<link>http://savvyadmin.com/bash-user-input-validation/comment-page-1/#comment-219</link>
		<dc:creator>Amarendra</dc:creator>
		<pubDate>Fri, 05 Sep 2008 10:53:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.savvyadmin.com/?p=62#comment-219</guid>
		<description>Interesting, and neat, especially the white-listing part.</description>
		<content:encoded><![CDATA[<p>Interesting, and neat, especially the white-listing part.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

