Shell Script for OS identification on all Platforms

Hi Mates,

I am writing a Shell script for identifying OS installed on the machine (it can Be any Unix like Solaris, AIX, RHEL, OEL, HP-UX ). With That I want to select appropriate software listed out in a file.

My Question here is, what are the appropriate flags to be used with "uname" command to accurately Identify OS and all necessary parameters like kernal (on all platforms), whoes entries I should maintain in the File along with software name.

I do not want to use "Uname -a"

Awaiting response from all.

Thanks

look into the file /etc/release

Hmm... flags. Maybe a script? :wink:

Hi itkamaraj,

I can't, because

  1. its not a common file across all platforms, neither the release files on all platform has common format.
  2. I want to have specific information (in a tabular form) in a file.

Example data I want to have in a csv file is something like below. ( I am expecting right columns/uname flags which are valid accross all platforms and can be mentioned appropriately against software verision

#OS(uname -o),HWP(uname -i),KrnlRelse (uname -r),SOFTWARE_Setup_NAME
GNU/Linux,i386,2.6.18-128.el5,wls1032_linux_i386.jar
GNU/Linux,i386,2.6.18-128.el5,oracle11gr2_linux_32bitx86

use uname with no arguments

Or use man uname (POSIX) with the options specified in the POSIX standard. Those (with 99% certainty) will work on any Unix/-compatible platform.

How about starting with

uname -s

?

From there, based on the OS, run OS specific commands to get the information you need.

Hi.

+1

The config.guess shell script referred to by yazu is very thorough and can discriminate among an impressive number of systems.

Even if you do not use config.guess directly, you may be able to learn something from how they determine the system, including the use of uname ... cheers, drl

Hi Purdym,

Yes,I am using the same approach, however I just want to understand what should be used on every specific platform in order to identify the software compatibility.

When we say a software is compatible for 32-bit/x86/i386 etc. what it refers to

is it processor type or hardware platform or hardware name (e.g. Linux Uname flags -p,-i or -m respectively) or its something else.
If you can clarify this I will be able to look for appropriate flags to be listed.

Thanks

At a macro level, it depends on:

  • Endianness, i.e. Big or Little
  • Data model, i.e. LP16, ILP32, LP64, etc.
  • Hardware architecture, i.e. x86, MIPS, SPARC, etc.

Hi.

The config.guess produces the signature on an AIX box as:

$ config.guess 
powerpc-ibm-aix5.1.0.0

on an HP box as:

$ config.guess 
hppa1.1-hp-hpux11.11

on a GNU/Debian Linux amd64 machine as:

% config.guess 
x86_64-unknown-linux-gnu

These are copies of the script without modification as run on those machines, simply ftp'd and run.

Best wishes ... cheers, drl