<?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: warning in a KSH script , which uses for HP-UX/LINUX in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764822#M657666</link>
    <description>&amp;gt;echo "${CHECK_DIGIT}" | grep -q "^[0-9]*$"&lt;BR /&gt;&lt;BR /&gt;As MK said, you typically use single quotes around grep/sed patterns that don't contain variables.  Especially if they contain backslash.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;if [ "$?" != "0" ]&lt;BR /&gt;&lt;BR /&gt;You should do a numeric compare on the exit status:&lt;BR /&gt;if [ $? -ne 0 ]; then</description>
    <pubDate>Mon, 14 Mar 2011 10:51:02 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2011-03-14T10:51:02Z</dc:date>
    <item>
      <title>warning in a KSH script , which uses for HP-UX/LINUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764819#M657663</link>
      <description>hello,&lt;BR /&gt;i am working mainly with KSH/HP-UX (11.31/ KSH Version ksh-88). but i have extend a KSH script for Linux (SLES 10 / KSH Version ksh-93t).&lt;BR /&gt;&lt;BR /&gt;i check my scripts for warnings,errors with "ksh -n &amp;lt;script&amp;gt;"&lt;BR /&gt;&lt;BR /&gt;for following statement i get warnings for Linux?&lt;BR /&gt;is HP-UX KSH or LINUX KSH right ?&lt;BR /&gt;&lt;BR /&gt;i want to check , if a environment variable has only digit(s) :&lt;BR /&gt;&lt;BR /&gt;Linux warning: &lt;BR /&gt;warning: line 121: $ not preceded by \&lt;BR /&gt;&lt;BR /&gt;statement:&lt;BR /&gt;echo "${CHECK_DIGIT}" |grep -q "^[0-9]*$"&lt;BR /&gt;&lt;BR /&gt;if [ "$?" != "0" ]&lt;BR /&gt;then&lt;BR /&gt;  echo "${CHECK_DIGIT} must be a numeric-integer value"&lt;BR /&gt;  exit 2&lt;BR /&gt;fi&lt;BR /&gt;</description>
      <pubDate>Mon, 14 Mar 2011 07:48:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764819#M657663</guid>
      <dc:creator>Billa-User</dc:creator>
      <dc:date>2011-03-14T07:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: warning in a KSH script , which uses for HP-UX/LINUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764820#M657664</link>
      <description>The message is a warning only: the shell understands what you mean, but wants to tell that it might be better to do something in a different way.&lt;BR /&gt;&lt;BR /&gt;I guess the warning comes from this:&lt;BR /&gt;&amp;gt; echo "${CHECK_DIGIT}" | grep -q "^[0-9]*$"&lt;BR /&gt;&lt;BR /&gt;In this, it would be the last $ sign at the end of search expression of the grep command: when seeing an unescaped $ inside double quotes, the shell expects to see a variable expansion of some sort. But since $" is not a valid variable expansion, the shell figures you meant a literal dollar sign, and the double quote is the end quote for the search expression.&lt;BR /&gt;&lt;BR /&gt;If you don't need to have any variables expanded inside grep's search expression, and the search expression includes characters with a special meaning to the shell (like "!" or "$"), then you might want to use single quotes instead of double quotes.&lt;BR /&gt;&lt;BR /&gt;echo "${CHECK_DIGIT}" | grep -q '^[0-9]*$'&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Mon, 14 Mar 2011 09:36:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764820#M657664</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2011-03-14T09:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: warning in a KSH script , which uses for HP-UX/LINUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764821#M657665</link>
      <description>&amp;gt; echo "${CHECK_DIGIT}" | grep -q '^[0-9]*$'&lt;BR /&gt;&lt;BR /&gt;thank you very much, you fix my problem. and i learned more about KSH</description>
      <pubDate>Mon, 14 Mar 2011 10:43:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764821#M657665</guid>
      <dc:creator>Billa-User</dc:creator>
      <dc:date>2011-03-14T10:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: warning in a KSH script , which uses for HP-UX/LINUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764822#M657666</link>
      <description>&amp;gt;echo "${CHECK_DIGIT}" | grep -q "^[0-9]*$"&lt;BR /&gt;&lt;BR /&gt;As MK said, you typically use single quotes around grep/sed patterns that don't contain variables.  Especially if they contain backslash.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;if [ "$?" != "0" ]&lt;BR /&gt;&lt;BR /&gt;You should do a numeric compare on the exit status:&lt;BR /&gt;if [ $? -ne 0 ]; then</description>
      <pubDate>Mon, 14 Mar 2011 10:51:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764822#M657666</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-03-14T10:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: warning in a KSH script , which uses for HP-UX/LINUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764823#M657667</link>
      <description>a new question about KSH:&lt;BR /&gt;&lt;BR /&gt;i wrote, i check my scripts for warnings,errors with "ksh -n &amp;lt;script&amp;gt;"&lt;BR /&gt;&lt;BR /&gt;i changed my shell script, but how i change this warning ?&lt;BR /&gt;example statement:&lt;BR /&gt;&lt;BR /&gt;teststring="aaa"&lt;BR /&gt;echo "aaa  " | grep -e "${teststring} *$"&lt;BR /&gt;&lt;BR /&gt;This is Linux warning:&lt;BR /&gt;warning: line 1: $ not preceded by \&lt;BR /&gt;&lt;BR /&gt;i can not change " to ' in this case ?!?&lt;BR /&gt;&lt;BR /&gt;is "ksh -n" a good way to check script for HP-UX, LINUX for the right syntax?&lt;BR /&gt;&lt;BR /&gt;HP-UX doesn't show a warning !&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Mar 2011 06:58:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764823#M657667</guid>
      <dc:creator>Billa-User</dc:creator>
      <dc:date>2011-03-25T06:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: warning in a KSH script , which uses for HP-UX/LINUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764824#M657668</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; i changed my shell script, but how i change this warning ?&lt;BR /&gt;&lt;BR /&gt;You can't, unless, perhaps, you managed your own, local message catalog.   Welcome to the subtle differences between GNU, HP-UX and the other Unixes.  Try AIX sometime.  Its messages are even more different and contain "standard" message numbers meaningful only to AIX.&lt;BR /&gt;&lt;BR /&gt;You don't want to concern yourself with the exact error/warning message text but rather the return code.  Return codes should be consistent among the various UNIX and LINUX implementations.  One similar example is with the 'ftpd' daemon where you are warned by the documentation not to rely on the exact text of the message, but rather examine the three-digit response code.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; is "ksh -n" a good way to check script for HP-UX, LINUX for the right syntax?&lt;BR /&gt;&lt;BR /&gt;This checks for *errors* not warnings.  Of course, syntactically error free code still doesn't necessarily execute without warnings or unforeseen consequences :-)&lt;BR /&gt;&lt;BR /&gt;Remember that the shell is *interpreted* code, and thus to some extent only until a piece is interpreted are all the states relative to the data known.&lt;BR /&gt;&lt;BR /&gt;I do find, that the GNU tools are far richer than the standard HP-UX (or AIX, etc.) ones, though .&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Mar 2011 11:24:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764824#M657668</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-03-25T11:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: warning in a KSH script , which uses for HP-UX/LINUX</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764825#M657669</link>
      <description>&amp;gt;warning: line 1: $ not preceded by \&lt;BR /&gt;&lt;BR /&gt;You can simply add that "\" before the "$".&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I can not change " to ' in this case?!?&lt;BR /&gt;&lt;BR /&gt;You can but that will stutter your quotes and make it less readable:&lt;BR /&gt;...| grep -e "${teststring}"' *$'</description>
      <pubDate>Fri, 25 Mar 2011 22:42:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/warning-in-a-ksh-script-which-uses-for-hp-ux-linux/m-p/4764825#M657669</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-03-25T22:42:05Z</dc:date>
    </item>
  </channel>
</rss>

