Re: How to check Solaris version in a script?



Dan Foster wrote:
In article <449f70b2$0$9370$baae4c71@xxxxxxxxxxxxxxxxx>, Sun_Powered <sun_powered@xxxxxxxxxxxxx> wrote:

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. :)
.



Relevant Pages

  • Re: Parsing strings in CGI scripts
    ... Seeing as you're using Solaris, you can take advantage of the printf ... command and the \0 echo sequence to convert the hexadecimal number back ... into its ASCII char. ... E.g my CGI scripts gets the following string ...
    (comp.unix.shell)
  • Re: Oracle 9i on Solaris 10
    ... Can anyone please share how you set the Oracle /etc/system settings on ... Solaris 10 is fundamentally different and uses a tool to set ... Running Oracle Database in Solaris 10 Containers - Best ... echo "Not required in Solaris 10"; ...
    (comp.databases.oracle.server)
  • Re: problems with lp using options like landscape, duplex, etc
    ... on a Solaris 10 box I would like to hear about it. ... yes, on solaris 10 machines, i replaced solaris binaries by cups binaries found in /opt/sfw/cups ... echo "Usage: $0 view|on e.g." ... echo 'Les commandes sont executees' ...
    (comp.unix.solaris)
  • Re: Oracle 9i on Solaris 10
    ... Can anyone please share how you set the Oracle /etc/system settings on ... Solaris 10 is fundamentally different and uses a tool to set ... echo "Not required in Solaris 10"; ...
    (comp.databases.oracle.server)
  • start script not working on solaris 10
    ... I've been using a variant of the script below on solaris 8 and 9 ... su - USERNAME -c somecommand ... echo "Starting ..." ...
    (comp.unix.solaris)