LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-06-2004, 05:50 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Is there a good way to find the OS version number?


I've got 14 machines running 3 OS's - RH7.3, RH9, Sus9.1. The RH9 & Suse9 machines can run the same executables, but the RH7.3 machines cannot run the same as the RH9 & Suse9 machines.

I'm trying to write a script that runs on each machine & points that machine to the correct executables (in shared space) based on the OS version. The only way I know how to get the version is rpm -qa | grep release (or something like that) & then do some if statements to see what matches.

While this will work, it's slow & not very elegant. Is there a better way of getting the version number? I'd love it if I could get just "7.3" or, even better, "7" when I ask for something like "major release" - that way, I could use the return of the command in the path to the executables - i.e. /shared/`find major-release`/dir/. Does something like this exist?
 
Old 10-06-2004, 05:52 PM   #2
Samsara
Member
 
Registered: May 2003
Distribution: Ubuntu, Mac OS X Tiger
Posts: 481

Rep: Reputation: 32
man nmap

HTH,

Samsara
 
Old 10-06-2004, 06:10 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,966
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
Re: Is there a good way to find the OS version number?

Quote:
Originally posted by BrianK
I've got 14 machines running 3 OS's - RH7.3, RH9, Sus9.1. The RH9 & Suse9 machines can run the same executables, but the RH7.3 machines cannot run the same as the RH9 & Suse9 machines.

I'm trying to write a script that runs on each machine & points that machine to the correct executables (in shared space) based on the OS version. The only way I know how to get the version is rpm -qa | grep release (or something like that) & then do some if statements to see what matches.

While this will work, it's slow & not very elegant. Is there a better way of getting the version number? I'd love it if I could get just "7.3" or, even better, "7" when I ask for something like "major release" - that way, I could use the return of the command in the path to the executables - i.e. /shared/`find major-release`/dir/. Does something like this exist?
That "major_release" is not all that different from your
first idea ;) ... rpm -qa on a fast machine should be easy
and quick enough, too.

I currently can't get my hands on a SuSE machine, but
it may well be that there's a /etc/suse-version file ...
there's one on redhat (/etc/redhat-release) which would
make the parsing quite simple.


Cheers,
Tink
 
Old 10-06-2004, 06:17 PM   #4
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Re: Re: Is there a good way to find the OS version number?

Quote:
Originally posted by Tinkster
That "major_release" is not all that different from your
first idea ... rpm -qa on a fast machine should be easy
and quick enough, too.

I currently can't get my hands on a SuSE machine, but
it may well be that there's a /etc/suse-version file ...
there's one on redhat (/etc/redhat-release) which would
make the parsing quite simple.
ahh.. Thanks Tink. There is, in fact, /etc/SuSE-release on the Suse box.

Not quite as spoon fed as I'd like to be, but I can work with this. Thanks!
 
Old 10-06-2004, 06:22 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,966
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
awk '{for(i=1; i <= NF;i++){if( $i ~ /[0-9]/) print $i}}' /etc/*version* | cut -d. -f 1

I'm sure there's an easier way of getting that :}


Cheers,
Tink

Last edited by Tinkster; 10-06-2004 at 06:24 PM.
 
Old 10-06-2004, 06:37 PM   #6
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Quote:
Originally posted by Tinkster
awk '{for(i=1; i <= NF;i++){if( $i ~ /[0-9]/) print $i}}' /etc/*version* | cut -d. -f 1

I'm sure there's an easier way of getting that :}
the uncharted territory of "awk" - looks interesting.

Thanks again!
 
Old 10-06-2004, 10:54 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,966
Blog Entries: 11

Rep: Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865Reputation: 865
You're welcome ;)

Feel free to affero me if this helped :)


Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting the Linux Distribution Name and Version Number s&j Linux - General 9 08-12-2012 06:22 PM
where is slackware version number? davidsrsb Slackware 3 09-08-2004 05:38 AM
unsupported btree version number 8 matttail Linux - Software 3 08-31-2004 09:19 PM
How do I specify a version number to use? Seventh Linux - Newbie 1 08-26-2004 04:29 PM
Checking Software Version Number Ezekiel Linux - Newbie 1 04-24-2002 05:24 PM


All times are GMT -5. The time now is 09:55 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration