How to check Solaris version in a script?

How to check Solaris version in a script?

Post by Sun_Powere » Tue, 27 Jun 2006 14:11:42



The uname command returns SunOS 5.1 (or some other number) but that
doesn't tell me if it's Solaris 8, 9, or 10 on that machine.

I need to something that I can use in a script.

Thanks in advance!

 
 
 

How to check Solaris version in a script?

Post by Dan Foste » Tue, 27 Jun 2006 14:22:19



Quote:> The uname command returns SunOS 5.1 (or some other number) but that
> doesn't tell me if it's Solaris 8, 9, or 10 on that machine.

> I need to something that I can use in a script.

Sure thing. Here you go:

#!/bin/sh

# Get OS version
osver=`uname -r`

# Check OS version
if [ ${osver} = "5.8" ]; then
        echo "Solaris 8"
elif [ ${osver} = "5.9" ]; then
        echo "Solaris 9"
elif [ ${osver} = "5.10" ]; then
        echo "Solaris 10"
else
        echo "Unknown or unsupported OS version"
fi

# We're done, let user know this script completed successfully
exit 0

Modify as you need.

Quote:> Thanks in advance!

You're welcome.

New to Solaris? Might want to read the Solaris FAQ here:

http://www.science.uva.nl/pub/solaris/solaris2.html

See the answer to question 1.5.

It has a table that lists Solaris version and its corresponding SunOS
version number (the uname -r output).

If you're new to Solaris, you *definitely* want to read the whole FAQ,
from start to finish... and re-read it as many times as you need to. It
helped me a lot 10 years ago.

-Dan

 
 
 

How to check Solaris version in a script?

Post by Paul Pluzhniko » Tue, 27 Jun 2006 14:26:57



> The uname command returns SunOS 5.1 (or some other number) but that
> doesn't tell me if it's Solaris 8, 9, or 10 on that machine.

It does. Do "man uname", look at the '-r' flag.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.

 
 
 

How to check Solaris version in a script?

Post by Sun_Powere » Tue, 27 Jun 2006 16:27:26




>>The uname command returns SunOS 5.1 (or some other number) but that
>>doesn't tell me if it's Solaris 8, 9, or 10 on that machine.

>>I need to something that I can use in a script.

> Sure thing. Here you go:

> #!/bin/sh

> # Get OS version
> osver=`uname -r`

> # Check OS version
> if [ ${osver} = "5.8" ]; then
>    echo "Solaris 8"
> elif [ ${osver} = "5.9" ]; then
>    echo "Solaris 9"
> elif [ ${osver} = "5.10" ]; then
>    echo "Solaris 10"
> else
>    echo "Unknown or unsupported OS version"
> fi

> # We're done, let user know this script completed successfully
> exit 0

> Modify as you need.

>>Thanks in advance!

> You're welcome.

> New to Solaris? Might want to read the Solaris FAQ here:

> http://www.science.uva.nl/pub/solaris/solaris2.html

> See the answer to question 1.5.

> It has a table that lists Solaris version and its corresponding SunOS
> version number (the uname -r output).

> If you're new to Solaris, you *definitely* want to read the whole FAQ,
> from start to finish... and re-read it as many times as you need to. It
> helped me a lot 10 years ago.

> -Dan

Thanks a lot for the script and the FAQ link, Dan!!

I'll be sure to read it. :)

 
 
 

How to check Solaris version in a script?

Post by Richard B. Gilber » Tue, 27 Jun 2006 20:32:03



> The uname command returns SunOS 5.1 (or some other number) but that
> doesn't tell me if it's Solaris 8, 9, or 10 on that machine.

> I need to something that I can use in a script.

> Thanks in advance!

uname -r will return 5.6 for Solaris 2.6, 5.7 for Solaris 7 (2.7) 5.8
for Solaris 8, 5.9 for Solaris 9.  I presume that it will return 5.10
for Solaris 10 but I haven't installed Solaris 10 yet.

Don't try to understand the numbering scheme, it will drive you mad!
Just accept it.

 
 
 

How to check Solaris version in a script?

Post by Chris Rid » Tue, 27 Jun 2006 20:57:10


On 2006-06-26 12:32:03 +0100, "Richard B. Gilbert"


>> The uname command returns SunOS 5.1 (or some other number) but that
>> doesn't tell me if it's Solaris 8, 9, or 10 on that machine.

>> I need to something that I can use in a script.

>> Thanks in advance!

> uname -r will return 5.6 for Solaris 2.6, 5.7 for Solaris 7 (2.7) 5.8
> for Solaris 8, 5.9 for Solaris 9.  I presume that it will return 5.10
> for Solaris 10 but I haven't installed Solaris 10 yet.

It does indeed return "5.10" on Solaris 10.

Cheers,

Chris

 
 
 

How to check Solaris version in a script?

Post by Thommy M. Malmstr? » Tue, 27 Jun 2006 21:32:22




>> The uname command returns SunOS 5.1 (or some other number) but that
>> doesn't tell me if it's Solaris 8, 9, or 10 on that machine.

>> I need to something that I can use in a script.

>> Thanks in advance!

> uname -r will return 5.6 for Solaris 2.6, 5.7 for Solaris 7 (2.7) 5.8
> for Solaris 8, 5.9 for Solaris 9.  I presume that it will return 5.10
> for Solaris 10 but I haven't installed Solaris 10 yet.

> Don't try to understand the numbering scheme, it will drive you mad!
> Just accept it.

You just described it. It's no more complicated than that. The last
number is the Solaris version...

#!/bin/sh

solver=`uname -r|cut -d. -f 2`
printf "You are currently running "

if [ ${solver} -le 6 ]; then
    printf "Solaris 2.$solver\n"
else
    printf "Solaris $solver\n"
fi

 
 
 

How to check Solaris version in a script?

Post by fabrice-pas-despame.bacche.. » Wed, 28 Jun 2006 07:51:21




>On 2006-06-26 12:32:03 +0100, "Richard B. Gilbert"


>>> The uname command returns SunOS 5.1 (or some other number) but that
>>> doesn't tell me if it's Solaris 8, 9, or 10 on that machine.

>>> I need to something that I can use in a script.

>>> Thanks in advance!

>> uname -r will return 5.6 for Solaris 2.6, 5.7 for Solaris 7 (2.7) 5.8
>> for Solaris 8, 5.9 for Solaris 9.  I presume that it will return 5.10
>> for Solaris 10 but I haven't installed Solaris 10 yet.

>It does indeed return "5.10" on Solaris 10.

And even 5.11 on Solaris Express, soon to be Solaris 11. That's
impressive.

- Show quoted text -

Quote:

>Cheers,

>Chris

 
 
 

1. How could I check the Solaris version

Hello Solaris Wizards ! Please could you tell me how could I know the
version of my Solaris OS ? I mean, is there any unix command doing so ?

Another question. I do not know how to access into the CD rom device and
read the files, should I mount the devise every time I want to access it ?
What's the command ?

Thank-You Wizards.

Octavio

2. Kernel config options

3. 2.3 install check script doesn't check

4. Help! Spammers are relaying throug me

5. A script that will only check file if it has been modified since last check

6. Security Flaw in IPTables FTP Connection Tracking

7. Best way to check available RAM from a script (Solaris 5.6)

8. qfe auto negotiation, Solaris2.6

9. shell script to determine remote OS version (solaris)

10. In search of Solaris 2.5 Netscape Navigator 3.0 plug ins

11. Code fragments/plug-ins for solaris?

12. SunOS version v Solaris version

13. which xntp (solaris version or the latest version) should be used