<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Filtering for specific chars. in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050029#M93536</link>
    <description>In the shebang line of your script add a '-f' flag to sh so that it looks like:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh -f&lt;BR /&gt;&lt;BR /&gt;The '-f' turns OFF file name generation, which is what the '*' is doing.</description>
    <pubDate>Wed, 30 May 2007 15:52:19 GMT</pubDate>
    <dc:creator>Patrick Wallek</dc:creator>
    <dc:date>2007-05-30T15:52:19Z</dc:date>
    <item>
      <title>Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050024#M93531</link>
      <description>&lt;!--!*#--&gt;Guys:&lt;BR /&gt;&lt;BR /&gt;/bin/sh, shell script, asks for user input and reads user input. The current script allows the user to input ANY character for comments. These comments are then written to a file that gets built on the fly and saved as an XML file. Further, a "home grown" interpreter/file parsing utility takes this xml file and reads it into another application. Finally, this app EXPLODES if any of the following characters have been input, at the beginning, by the user....&lt;BR /&gt;&lt;BR /&gt;*, @, #, $, % and &amp;amp;.&lt;BR /&gt;&lt;BR /&gt;Does anyone out there have a good method for looking at the user input string to verify whether or not it contains the above forbidden characters?&lt;BR /&gt;&lt;BR /&gt;For example, the user might input a string like:&lt;BR /&gt;&lt;BR /&gt;The upper &amp;amp; lower limits are out-of-range.&lt;BR /&gt;&lt;BR /&gt;The character "&amp;amp;" is the problem. I'd like to be able to simply loop back, clear the string, give the user an error message flagging the illegal character and have them resubmit the comment with only alpha chars. I don't need any looping, etc stuff, just a working method to sense the illegal chars.&lt;BR /&gt;&lt;BR /&gt;Any ideas? Thanks.</description>
      <pubDate>Wed, 30 May 2007 13:51:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050024#M93531</guid>
      <dc:creator>john guardian</dc:creator>
      <dc:date>2007-05-30T13:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050025#M93532</link>
      <description>&lt;!--!*#--&gt;Hi John:&lt;BR /&gt;&lt;BR /&gt;This shell script shows one way:&lt;BR /&gt;&lt;BR /&gt;cat .myfilter&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;    read LINE&lt;BR /&gt;    echo ${LINE}|grep -q -e '\*' -e '\@' -e '\#' -e '\$' -e '\%' -e '\&amp;amp;'&lt;BR /&gt;    [ $? = 0 ] &amp;amp;&amp;amp; echo "REJECTED!" || echo "ok"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;...run as ./myfilter&lt;BR /&gt;&lt;BR /&gt;...and type sample lines with/without the characters you want to filter.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 30 May 2007 14:15:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050025#M93532</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-30T14:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050026#M93533</link>
      <description>grep -cE '\@|\*|\#|\$|\%|\&amp;amp;'&lt;BR /&gt;&lt;BR /&gt;will return a 1 if one of the characters is found and 0 if not.</description>
      <pubDate>Wed, 30 May 2007 14:20:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050026#M93533</guid>
      <dc:creator>Court Campbell</dc:creator>
      <dc:date>2007-05-30T14:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050027#M93534</link>
      <description>&lt;!--!*#--&gt;Guys, the above grep statements work great for everything "except" the '*' char. Instead of interpreting it as it does all of the other chars, it instead interprets the '*' as the list of all files and/or dirs in the current directory. &lt;BR /&gt;&lt;BR /&gt;That's the problem that I ran into... which is why I asked for other solutions. &lt;BR /&gt;&lt;BR /&gt;I appreciate the input... any other suggestions would also be appreciated.&lt;BR /&gt;&lt;BR /&gt;Thanks.</description>
      <pubDate>Wed, 30 May 2007 15:40:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050027#M93534</guid>
      <dc:creator>john guardian</dc:creator>
      <dc:date>2007-05-30T15:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050028#M93535</link>
      <description>Hi (again) JOhn:&lt;BR /&gt;&lt;BR /&gt;Ooops, a bit careless, I was:&lt;BR /&gt;&lt;BR /&gt;Quote the variable as:&lt;BR /&gt;&lt;BR /&gt;# echo "${LINE}"|grep -q -e '\*' -e '\@' -e '\#' -e '\$' -e '\%' -e '\&amp;amp;'&lt;BR /&gt;&lt;BR /&gt;# cat .myfilter&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;while true&lt;BR /&gt;do&lt;BR /&gt;    read LINE&lt;BR /&gt;    echo "${LINE}"|grep -q -e '\*' -e '\@' -e '\#' -e '\$' -e '\%' -e '\&amp;amp;'&lt;BR /&gt;    [ $? = 0 ] &amp;amp;&amp;amp; echo "REJECTED!" || echo "ok"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 30 May 2007 15:50:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050028#M93535</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-30T15:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050029#M93536</link>
      <description>In the shebang line of your script add a '-f' flag to sh so that it looks like:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh -f&lt;BR /&gt;&lt;BR /&gt;The '-f' turns OFF file name generation, which is what the '*' is doing.</description>
      <pubDate>Wed, 30 May 2007 15:52:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050029#M93536</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2007-05-30T15:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050030#M93537</link>
      <description>&amp;gt;JRF: -e '\*' -e '\@' -e '\#' -e '\$' -e '\%' -e '\&amp;amp;'&lt;BR /&gt;&lt;BR /&gt;Any reason you are using both types of quoting?&lt;BR /&gt;It would seem that you could just use fgrep so you wouldn't have to use \*.  And the rest aren't special regexp(5) chars.</description>
      <pubDate>Wed, 30 May 2007 21:00:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050030#M93537</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2007-05-30T21:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050031#M93538</link>
      <description>This may not be the complete list of special characters...indeed, what happens when the user types CTRL-G or some other special character? Another way to find special characters on a line is to use tr and character classes to remove the acceptable characters and if anything is left, the result is a list of unacceptable characters. The classes of characters are:&lt;BR /&gt;&lt;BR /&gt;alnum, alpha, blank, cntrl,                       digit, graph, lower, print, punct, space, upper, xdigit&lt;BR /&gt; &lt;BR /&gt;Use something like this:&lt;BR /&gt;&lt;BR /&gt;### more code ###&lt;BR /&gt;read LINE&lt;BR /&gt;BADCHARS=$(echo "$LINE" | tr -d '[:alnum:]')&lt;BR /&gt;if [ ${#BADCHARS} -gt 0 ]&lt;BR /&gt;then&lt;BR /&gt;VIEWBAD=$(echo "$BADCHARS" | cat -v)&lt;BR /&gt;echo "Unacceptable characters: $VIEWBAD"&lt;BR /&gt;### more error handling ###&lt;BR /&gt;else&lt;BR /&gt;echo OK&lt;BR /&gt;fi&lt;BR /&gt; &lt;BR /&gt;You can change the character class to [:alpha:] to eliminate numbers or other character classes may be combined with subsequent tr commands.</description>
      <pubDate>Thu, 31 May 2007 07:14:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050031#M93538</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-05-31T07:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050032#M93539</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;Dennis wrote:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; JRF: -e '\*' -e '\@' -e '\#' -e '\$' -e '\%' -e '\&amp;amp;'&lt;BR /&gt;&lt;BR /&gt;Any reason you are using both types of quoting?&lt;BR /&gt;&lt;BR /&gt;Yes, although for other than '\$' both types of quouting were over-kill and I used them only for consistency.&lt;BR /&gt;&lt;BR /&gt;What I was avoiding was matching any newline as:&lt;BR /&gt;&lt;BR /&gt;# echo "\n"|grep -q \$ &amp;amp;&amp;amp; echo NOT_WANTED!&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 31 May 2007 07:47:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050032#M93539</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-05-31T07:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering for specific chars.</title>
      <link>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050033#M93540</link>
      <description>Thanks, again!</description>
      <pubDate>Fri, 15 Jun 2007 11:28:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/filtering-for-specific-chars/m-p/5050033#M93540</guid>
      <dc:creator>john guardian</dc:creator>
      <dc:date>2007-06-15T11:28:25Z</dc:date>
    </item>
  </channel>
</rss>

