How to difinitively id. solaris from shell?

How to difinitively id. solaris from shell?

Post by Shawn Hughe » Thu, 15 May 1997 04:00:00



I have a shell script in which the line

if [ $ARCH = "Solaris" ]
   then ...

This variable was not set on a Solaris machine and caused
some problems.  Can I check something else?

The existance of /vmunix?

Shawn.

 
 
 

How to difinitively id. solaris from shell?

Post by Fletcher.Gl.. » Thu, 15 May 1997 04:00:00


Try looking at the output from "uname -r" and see if you can
make a test from that.



Quote:>I have a shell script in which the line

>if [ $ARCH = "Solaris" ]
>   then ...

>This variable was not set on a Solaris machine and caused
>some problems.  Can I check something else?

>The existance of /vmunix?

>Shawn.


 
 
 

How to difinitively id. solaris from shell?

Post by Andrey Ryzho » Fri, 16 May 1997 04:00:00



> I have a shell script in which the line

> if [ $ARCH = "Solaris" ]
>    then ...

> This variable was not set on a Solaris machine and caused
> some problems.  Can I check something else?

> The existance of /vmunix?

> Shawn.

You probably can do

if [ "`uname -r | awk -F. '{print $1}'`" = "5" ] ; then ... ; fi

Andrey

 
 
 

How to difinitively id. solaris from shell?

Post by Timothy J. L » Fri, 16 May 1997 04:00:00


|I have a shell script in which the line
|
|if [ $ARCH = "Solaris" ]
|   then ...
|
|This variable was not set on a Solaris machine and caused
|some problems.  Can I check something else?

Try using the output of uname.  On SunOS / Solaris, `uname` will
be "SunOS" (as opposed to something like "AIX", "HP-UX", etc.),
and `uname -r` will give a version number like "4.1.3_U1" or "5.5.1".

--
------------------------------------------------------------------------

Unsolicited bulk or commercial email is not welcome.             netcom.com
No warranty of any kind is provided with this message.

 
 
 

How to difinitively id. solaris from shell?

Post by Guy Harr » Fri, 16 May 1997 04:00:00



Quote:>You probably can do

>if [ "`uname -r | awk -F. '{print $1}'`" = "5" ] ; then ... ; fi

...unless you also want this script to work on, say, IRIX 5.x and don't
want it to think IRIX 5.x is Solaris of some sort.

You really want to look at "uname -s" as well, e.g. doing "uname -sr"
and looking for "SunOS 5.*" if you want to see whether you're on Solaris
2.x (and "SunOS 4.*" for Solaris 1.x).

 
 
 

How to difinitively id. solaris from shell?

Post by Dan Abarbane » Fri, 16 May 1997 04:00:00



> I have a shell script in which the line

> if [ $ARCH = "Solaris" ]
>    then ...

> This variable was not set on a Solaris machine and caused
> some problems.  Can I check something else?

OS=`uname -s`
if [ "$OS" = "SunOS" ] ; then # Could be SunOS 4.x or 5.x
        RELEASE=`uname -r | cut -c1` # Get the Major Version digit
        case $RELEASE in
                4) ;; # Just use "SunOS" as identifier
                5) OS="Solaris" ;; # Or whatever you want
                *) /bin/echo "Huh?"
                   exit ;; # Or use some kind of default, or whatever
        esac
fi
# Now $OS holds what you want...

Hope this helps

--
======================================================================
Dan Abarbanel                 | "Warning: Dates in the calendar are
Madge Networks ESD, Israel    |  closer than they appear!"
Tel: +972 3 6457662           |
Fax: +972 3 6487146           |