Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get an OS kernel/release information?

Status
Not open for further replies.

whn

Programmer
Oct 14, 2007
265
US
Experts,

I need to write a perl code to find out what an OS kernel/release information is. For example, suppose I am on a Linux box. I can obtain following info:

Code:
% cat /etc/issue

Welcome to SUSE LINUX Enterprise Server 9 (x86_64) - Kernel \r (\l).

% uname -a
Linux lcle222 2.6.5-7.244-smp #1 SMP Mon Dec 12 18:32:25 UTC 2005 x86_64 x86_64 x86_64 GNU/Linux

But how can I tell if it's RHEL 4 U6 (32-bit, 64-bit, IA64) or SLES 10 SP1 (32-bit, IA64) or SLES 9 SP2 (32-bit, IA64), etc?

BTW, I know SUSE is SLES. The above just an example. I searched CPAN site, still don't know what module I can use. if you happen to know a module I can use, please also kindly show me some sample codes on how to use that module.

Many thanks.
 
I don't think this is a Perl question really. I'd ask in one of the Linux forums. It'll just be a case of running the desired command using qx or the backticks operator.
 
I'd think there should be certain perl modules which can get the same info as 'uname -a' does. I checked cpan site, it seems to me that Linux-Bootloader module (linux_release_tag , specifically) could do the job. but I don't know how to use it. The doc is too simple and does give any examples.

I was hoping someone here could tell me what module to use and provide a sample code on using that module (whatever it is).
 
On my FC8 box you can get some reasonable info back from a
Code:
cat /proc/version
which produces
Code:
Linux version 2.6.23.15-137.fc8 (mockbuild@xenbuilder2.fedora.redhat.com) (gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)) #1 SMP Sun Feb 10 17:48:34 EST 2008
There are a few other /proc files like meminfo that have useful stuff.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
thank you, steve.

What i am looking for is whether ther is a perl module which can give the kernel info for all platforms so that I don't need to run `cat /proc/version` or `cat /etc/issue`, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top