is it SUSE or RHEL or Debian. How to detect programmatically?


 
Thread Tools Search this Thread
Top Forums Programming is it SUSE or RHEL or Debian. How to detect programmatically?
# 1  
Old 12-04-2008
Java is it SUSE or RHEL or Debian. How to detect programmatically?

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

Last edited by krishnamurthig; 12-04-2008 at 08:50 AM.. Reason: More info on subject
# 2  
Old 12-04-2008
I know that RHEL, and suse usually have a file named "/etc/issue", which contains Distribution and Version info, but I'm not so sure about debian.

Hope that helps.


edit: whoops, didnt see you're part about /etc/issue...sorry.
# 3  
Old 12-05-2008
You can use the command as follows.
#uname -a

Refer the man page of 'uname' for more details.
# 4  
Old 12-05-2008
Also look at the /etc/*release file.
# 5  
Old 12-05-2008
Deleted by myself,

reason: didn't read whole post.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Help with detaching the screen programmatically

Hi, I am using screen utility for protecting from ssh disconnects. My process flow i ssomething like : a) I start screen from my desktop terminl. b)In the screen session, i ssh to one host and execute a command c)Once the above command is completed,i would like to exit via ctr-a or... (4 Replies)
Discussion started by: pandeesh
4 Replies

2. Solaris

How to programmatically reset a users password.?

Hello all, I have a small C++ app for my solaris admins. I need to set it up so they can reset a users password. The admin does not have the old password. How can I reset a users password to a temp password either using passwd or PAM? I need to do this from within my C++ app. I have searched... (3 Replies)
Discussion started by: ChickenPox
3 Replies

3. Red Hat

Unable to detect HP backup tapes in RHEL 6.2

Hi All, We connected 2 new tape drives to the servers. I am not able to see both HP tape drives in OS level. I am using RHEL 6.2 OS. I have scanned and rebooted the server but still can't able to find the drives. Thanks in advance..!!!! ---------- Post updated 10-22-13 at 05:07 PM... (1 Reply)
Discussion started by: Navkreddy
1 Replies

4. Red Hat

Error throwing while installing vsftpd package in rhel 6. using rhel 6 dvd.

Hi all, Im studying rhcsa as of now, so yum installation and dependencies are messing me to not workit out. i have dual os, win 7 & rhel 6. i have tried this installation of vsftpd package with rhel 6 dvd in VM rhel 6 in win 7 as well as host rhel 6.still the same issue. below error... (6 Replies)
Discussion started by: redhatlbug
6 Replies

5. UNIX for Dummies Questions & Answers

SSH from MacOS X or PPC Debian to SUSE # Odd terminal chars # Eventual scripting

Well. I was recently given access to my work's machine via SSH. I'm pretty sure it's a SUSE machine, uname -a gives Linux machinename 2.6.16.60-0.54.5-bigsmp #1 SMP Fri Sep 4 01:28:03 UTC 2009 i686 i686 i386 GNU/Linux I'm not doing anything all that exciting, mostly data entry stuff. We... (14 Replies)
Discussion started by: pagrus
14 Replies

6. Shell Programming and Scripting

how to programmatically generate makefile variable

I make to parse the release version from a text file and set the release version label into a Makefile variable. I tried: VERSION := `grep vsn s1db.app|sed -e s/*\"// -e s/\"*//` but looks like make, unlike shell, literally just take the entire `grep ...` as the variable value. Then I tried... (3 Replies)
Discussion started by: benkial
3 Replies

7. UNIX for Advanced & Expert Users

need sample system o/p RHEL/Debian

Hi, Could somebody sent me sample output of below commands on 1) Debian linux and 2) RHEL3 and 3) any RHEL version less than 3, a) uname -a b) cat /etc/issue c) cat /etc/redhat-release or other equivalent file Thanks in advance - Krishna (0 Replies)
Discussion started by: krishnamurthig
0 Replies

8. Programming

Check the Disk usage Programmatically

Hi all, Do we have anyway to get the freediskspace for within a C program? I need functionality similar to 'df -h' -> which gives the % of utilization... Otherwise, if we go and use 'system ("df -h /home/myhome/")', do we have any way of capturing the output into a string and parse the... (2 Replies)
Discussion started by: SriSri
2 Replies

9. Programming

how to find usb ports programmatically

I need to find out where a usb flash memory drive is mounted. I have used prtconf and iostat to find the information and then used popen to parse the information to find what i need. I am wondering if there are some generic functions such as ddi_ or usb_ that i can use to find such info. I would... (1 Reply)
Discussion started by: jtcoelho
1 Replies

10. Solaris

Modify Style Manager programmatically

My Java application runs on SunOS 5.8. Our use of a 3rd party class requires us to modify the Style Manager-Window setting "Allow Primary Windows On Top" - the default for this is on, we need to turn it off. Is there any way for our application, or our installation, to modify this setting? We... (0 Replies)
Discussion started by: ped52
0 Replies
Login or Register to Ask a Question