<?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: script error in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098762#M807181</link>
    <description>the == is arithmetic operator and your using the obsoleted [ ]. use the (( )) syntax for and you won't get the error.  But it still won't work.&lt;BR /&gt;&lt;BR /&gt;first of all the tic '..' are obsolete too. use $(..) instead.  &lt;BR /&gt;&lt;BR /&gt;$? is the return code of the last command. I would guess that your expecting a 0 for success.  So, what your doing is running the command echo 0, take it's return code (which should be 0 as long as you can write to stdout), and then test if it is the value 0.&lt;BR /&gt;so what your actually testing is if echo $? was successfull and not the ls.&lt;BR /&gt;&lt;BR /&gt;probably what your wanting to do is &lt;BR /&gt;if [[ "$?" = "0" ]] ;then&lt;BR /&gt;#success&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;or&lt;BR /&gt;if (( $? = 0 )) ;then&lt;BR /&gt;#success&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.</description>
    <pubDate>Tue, 21 Oct 2003 12:53:22 GMT</pubDate>
    <dc:creator>curt larson_1</dc:creator>
    <dc:date>2003-10-21T12:53:22Z</dc:date>
    <item>
      <title>script error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098759#M807178</link>
      <description>I have written a script which takes if the previous command ran successfully or not. If the previous command ran successfully,then excecute the next command.&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;ls -l&lt;BR /&gt;if [ `echo $?` == 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo "success"&lt;BR /&gt;&lt;BR /&gt;else&lt;BR /&gt;echo "Failed"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;But its giving an error,&lt;BR /&gt;==: 0403-012 A test command parameter is not valid.&lt;BR /&gt;&lt;BR /&gt;any ideas ..why?&lt;BR /&gt;thanks.</description>
      <pubDate>Tue, 21 Oct 2003 12:33:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098759#M807178</guid>
      <dc:creator>Penny Patch</dc:creator>
      <dc:date>2003-10-21T12:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: script error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098760#M807179</link>
      <description>Change the code to following...&lt;BR /&gt;&lt;BR /&gt;ls -l&lt;BR /&gt;if [ $? -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;   echo "success"&lt;BR /&gt;else&lt;BR /&gt;   echo "Failed"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;To compare i think you would need to use&lt;BR /&gt;-eq, -gt, -lt, -le... to compare integers&lt;BR /&gt;&lt;BR /&gt;i don't think there is a comparison operator "==" for integer&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Oct 2003 12:44:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098760#M807179</guid>
      <dc:creator>Amin Jaffer_1</dc:creator>
      <dc:date>2003-10-21T12:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: script error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098761#M807180</link>
      <description>thry this&lt;BR /&gt;&lt;BR /&gt;ls -l&lt;BR /&gt;a=`echo $?`   ---or--- a=$(echo $?)&lt;BR /&gt;if [ "$a" -eq 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo scucces&lt;BR /&gt;else&lt;BR /&gt;echo faild&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;succes&lt;BR /&gt;&lt;BR /&gt;idriz&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Oct 2003 12:47:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098761#M807180</guid>
      <dc:creator>I.Delic</dc:creator>
      <dc:date>2003-10-21T12:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: script error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098762#M807181</link>
      <description>the == is arithmetic operator and your using the obsoleted [ ]. use the (( )) syntax for and you won't get the error.  But it still won't work.&lt;BR /&gt;&lt;BR /&gt;first of all the tic '..' are obsolete too. use $(..) instead.  &lt;BR /&gt;&lt;BR /&gt;$? is the return code of the last command. I would guess that your expecting a 0 for success.  So, what your doing is running the command echo 0, take it's return code (which should be 0 as long as you can write to stdout), and then test if it is the value 0.&lt;BR /&gt;so what your actually testing is if echo $? was successfull and not the ls.&lt;BR /&gt;&lt;BR /&gt;probably what your wanting to do is &lt;BR /&gt;if [[ "$?" = "0" ]] ;then&lt;BR /&gt;#success&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;or&lt;BR /&gt;if (( $? = 0 )) ;then&lt;BR /&gt;#success&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.</description>
      <pubDate>Tue, 21 Oct 2003 12:53:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098762#M807181</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-10-21T12:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: script error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098763#M807182</link>
      <description>Thanks Amin. That solved the</description>
      <pubDate>Tue, 21 Oct 2003 12:58:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098763#M807182</guid>
      <dc:creator>Penny Patch</dc:creator>
      <dc:date>2003-10-21T12:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: script error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098764#M807183</link>
      <description>Thanks all.</description>
      <pubDate>Tue, 21 Oct 2003 12:59:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-error/m-p/3098764#M807183</guid>
      <dc:creator>Penny Patch</dc:creator>
      <dc:date>2003-10-21T12:59:51Z</dc:date>
    </item>
  </channel>
</rss>

