Hi Gurus,
I want to programmatically detect what Linux flavour I have in my m/c, detailed OS-name and its version,
e.g. is it RHEL, SUSE, Debian etc.
----------------------------------------------------------------
Flavour OS-Nname version
----------------------------------------------------------------
RHEL3 RHEL 3.2
RHEL4 RHEL 4
RHEL5 RHEL 5.1
SLES9 SLES 10
SLES10 SLES 9
----------------------------------------------------------------
Thee is structre
"struct utsname uts;"
This structure doesn't give me above information. This can be found by looing at /etc/issue or /etc/redhat-release.
I appreciate if anyboy gives me hint/pointer how can I detect programmatically .
Some sample output here below,
mycomnp> cat /etc/issue
Welcome to SUSE Linux Enterprise Server 10 (ia64) - Kernel \r (\l).
mycomnp> uname -a
Linux mynode 2.6.16.21-0.8-default #1 SMP Mon Jul 3 18:25:39 UTC 2006 ia64 ia64 ia64 GNU/Linux
Output of utsname structure:
main()
{
struct utsname sys_inf;
uname\(&sys_inf\);
printf\("System name - %s \\n", sys_inf.sysname\);
printf\("Nodename - %s \\n", sys_inf.nodename\);
printf\("Release - %s \\n", sys_inf.release\);
printf\("Version - %s \\n", sys_inf.version\);
printf\("Machine - %s \\n", sys_inf.machine\);
}
System name - Linux
Nodename - mynode
Release - 2.6.16.21-0.8-default
Version - #1 SMP Mon Jul 3 18:25:39 UTC 2006
Machine - ia64
Thanks in advance
- Krishna