<?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 test oddity in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659033#M928802</link>
    <description>Hello all,&lt;BR /&gt;A few days I wrote a script to kill off old hung processes on a system.  One of the checks I do is to run a ps -ef and grab the 6th field.  If it's a question mark then the process is ok (as that means the time stamp is still the time), if it's anything else then it's an old process and should be killed (as the time stamp has converted to month/day and therefore created a new field).  &lt;BR /&gt;Anyway it works fine, except that I noticed that processes that had a date of the 7th weren't being killed.  After looking into this a bit I found that when I compare [ $x != ? ] (with the value of $x being 7) it considers them to be equal.  Below is a short test script that shows the issue.  Anyone know why this is?&lt;BR /&gt;&lt;BR /&gt;a=1&lt;BR /&gt;while [ $a -lt 10 ]&lt;BR /&gt;do&lt;BR /&gt;if [ $a != ? ]&lt;BR /&gt; then&lt;BR /&gt;  echo "not equal"&lt;BR /&gt; else&lt;BR /&gt;  echo "equal"&lt;BR /&gt;fi&lt;BR /&gt;a=`expr $a + 1`&lt;BR /&gt;done</description>
    <pubDate>Tue, 05 Feb 2002 15:12:05 GMT</pubDate>
    <dc:creator>Steve Sauve</dc:creator>
    <dc:date>2002-02-05T15:12:05Z</dc:date>
    <item>
      <title>test oddity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659033#M928802</link>
      <description>Hello all,&lt;BR /&gt;A few days I wrote a script to kill off old hung processes on a system.  One of the checks I do is to run a ps -ef and grab the 6th field.  If it's a question mark then the process is ok (as that means the time stamp is still the time), if it's anything else then it's an old process and should be killed (as the time stamp has converted to month/day and therefore created a new field).  &lt;BR /&gt;Anyway it works fine, except that I noticed that processes that had a date of the 7th weren't being killed.  After looking into this a bit I found that when I compare [ $x != ? ] (with the value of $x being 7) it considers them to be equal.  Below is a short test script that shows the issue.  Anyone know why this is?&lt;BR /&gt;&lt;BR /&gt;a=1&lt;BR /&gt;while [ $a -lt 10 ]&lt;BR /&gt;do&lt;BR /&gt;if [ $a != ? ]&lt;BR /&gt; then&lt;BR /&gt;  echo "not equal"&lt;BR /&gt; else&lt;BR /&gt;  echo "equal"&lt;BR /&gt;fi&lt;BR /&gt;a=`expr $a + 1`&lt;BR /&gt;done</description>
      <pubDate>Tue, 05 Feb 2002 15:12:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659033#M928802</guid>
      <dc:creator>Steve Sauve</dc:creator>
      <dc:date>2002-02-05T15:12:05Z</dc:date>
    </item>
    <item>
      <title>Re: test oddity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659034#M928803</link>
      <description>you have to escape the ? with the \ thus:&lt;BR /&gt;&lt;BR /&gt;if [ $a != \? ] &lt;BR /&gt;&lt;BR /&gt;so that the script interpreter does not use the ? as a special character.  Running your example script in ksh with the -x option to debug, you can see it makes 1=1.&lt;BR /&gt;&lt;BR /&gt;mark</description>
      <pubDate>Tue, 05 Feb 2002 15:24:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659034#M928803</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2002-02-05T15:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: test oddity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659035#M928804</link>
      <description>Thanks that did fix it.  Also tried it on a FreeBSD, HP-UX 11 and 11i box.  In all those cases it worked fine w/o the slash.  I wonder why it was just the number 7 that didn't work....&lt;BR /&gt;&lt;BR /&gt;Anyway, thanks again :)&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 05 Feb 2002 15:29:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659035#M928804</guid>
      <dc:creator>Steve Sauve</dc:creator>
      <dc:date>2002-02-05T15:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: test oddity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659036#M928805</link>
      <description>Hi Steve,&lt;BR /&gt;&lt;BR /&gt;Do you have a file named 7 in the directory where you run the script?  That would cause the problem.&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Tue, 05 Feb 2002 15:31:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659036#M928805</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-02-05T15:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: test oddity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659037#M928806</link>
      <description>huh..in fact I do.  Just got rid of it and suddenly 7 isn't equal to ? anymore :)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 05 Feb 2002 15:40:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659037#M928806</guid>
      <dc:creator>Steve Sauve</dc:creator>
      <dc:date>2002-02-05T15:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: test oddity</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659038#M928807</link>
      <description>Yep, figured as much.  As you already know from Mark's reply, you need to escape the ? so the shell won't expand it.  You could also quote it ("?").&lt;BR /&gt;&lt;BR /&gt;The shell turns ? (unless escaped or quoted) into the list of files in the current directory named with 1 character.  7 happened to be the first (or only one) in your directory.  If you had files named 3 and 7, 3 would not have "worked" and 7 would have "worked".&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Tue, 05 Feb 2002 20:20:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/test-oddity/m-p/2659038#M928807</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-02-05T20:20:08Z</dc:date>
    </item>
  </channel>
</rss>

