5 Replies Latest reply: Aug 27, 2013 7:20 AM by 982087 RSS

    Differences in writting bash-script in Solaris and in RHEL?

    user10501597

      I wrote a script 'checkinstall' as follow and it works fine by RHEL:

       

      [code]

      #!/bin/sh

       

       

      HOSTNAME=hostname

      echo $HOSTNAME

      if [ $HOSTNAME == "S001AP99-TEST" ]; then

          echo This is the wrong machine.\

          echo "\nAbouting installation.\n\n"

          exit 1

      fi

      exit 0

       

      [/code]

       

      But when I run this by Solaris I got:

       

      # ./checkinstall

      hostname

      ./checkinstall: test: unknown operator ==

       

      I changed the line HOSTNAME=hostname to HOSTNAME=`hostname` and it outputs the correct hostname.

       

      But I still get error:

      # ./checkinstall

      S001AP99-TEST

      ./checkinstall: test: unknown operator ==