Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > OS Version

Reply
Thread Tools

OS Version

 
 
Mark J Fenbers
Guest
Posts: n/a
 
      03-01-2004
$^O gives the O/S name, in my case : 'linux', but I want to run my Perl script
on RH 7.X and RH 9.x of Linux. How can my script determine which version of the
O/S it is running on?

Mark

 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      03-01-2004

Mark J Fenbers <> wrote:
>
> $^O gives the O/S name, in my case : 'linux', but I want to run my Perl script
> on RH 7.X and RH 9.x of Linux. How can my script determine which version of the
> O/S it is running on?


my $osvers = `uname -r`;

will return the OS version (at least on Linux). Note that this is the
kernel version, not the DeadRat distribution version.

> [Attachment type=text/x-vcard, name=Mark.Fenbers.vcf]


DON'T do that.

Ben

--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else **
 
Reply With Quote
 
 
 
 
Josef Möllers
Guest
Posts: n/a
 
      03-01-2004
Mark J Fenbers wrote:
>
> $^O gives the O/S name, in my case : 'linux', but I want to run my Perlscript
> on RH 7.X and RH 9.x of Linux. How can my script determine which version of the
> O/S it is running on?


RedHat (and SuSE, don't know about the others) have a file /etc/*release
which tells you the version of the installed distribution.
Not that the contents is anything standard.

Josef
--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      03-01-2004
Mark J Fenbers wrote:
> $^O gives the O/S name, in my case : 'linux', but I want to run my
> Perl script on RH 7.X and RH 9.x of Linux. How can my script
> determine which version of the O/S it is running on?


But linux is the operating system, isn't it?
RHxyz is the distribution, and has little to do with the OS

jue


 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      03-01-2004
On Mon, 01 Mar 2004 10:04:30 -0500, Mark J Fenbers wrote:

> $^O gives the O/S name, in my case : 'linux', but I want to run my Perl script
> on RH 7.X and RH 9.x of Linux. How can my script determine which version of the
> O/S it is running on?


Why should your script care about the distro of Linux?

More importantly, why are you coding to a certain distro of Linux?
That a little like making tall kitchen garbage bags to fit only a certain
vendor's tall kitchen garbage can

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Are you a turtle?


 
Reply With Quote
 
Mark J Fenbers
Guest
Posts: n/a
 
      03-01-2004
Well, because I have third-party software that I call from my script and that
software has to be called with different environmental settings on RH 9 than it does
for RH 7.

Mark

James Willmore wrote:

> On Mon, 01 Mar 2004 10:04:30 -0500, Mark J Fenbers wrote:
>
> > $^O gives the O/S name, in my case : 'linux', but I want to run my Perl script
> > on RH 7.X and RH 9.x of Linux. How can my script determine which version of the
> > O/S it is running on?

>
> Why should your script care about the distro of Linux?
>
> More importantly, why are you coding to a certain distro of Linux?
> That a little like making tall kitchen garbage bags to fit only a certain
> vendor's tall kitchen garbage can
>
> --
> Jim
>
> Copyright notice: all code written by the author in this post is
> released under the GPL. http://www.gnu.org/licenses/gpl.txt
> for more information.
>
> a fortune quote ...
> Are you a turtle?


 
Reply With Quote
 
Tore Aursand
Guest
Posts: n/a
 
      03-01-2004
On Mon, 01 Mar 2004 10:04:30 -0500, Mark J Fenbers wrote:
> $^O gives the O/S name, in my case : 'linux', but I want to run my Perl
> script on RH 7.X and RH 9.x of Linux.


Why? And have in mind that Red Hat is just a Linux distribution; The OS
is Linux no matter what distribution (of Linux) you're running.


--
Tore Aursand <>
"First, God created idiots. That was just for practice. Then He created
school boards." -- Mark Twain
 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      03-01-2004
Mark J Fenbers wrote:

> Well, because I have third-party software that I call from my script and that
> software has to be called with different environmental settings on RH 9 than it does
> for RH 7.


Why? If it is because one distribution as files in a particular
directory and the other does not, then test for the existence of
that directory.

Testing the OS (the version of the kernel) won't help.
$os = `uname -r`;
if ($os =~ /^2.4.20-28.\d+$/) {
print "Kernel version indicates patched RH7.1 or patched RH9\n";
}

-Joe
 
Reply With Quote
 
James Willmore
Guest
Posts: n/a
 
      03-01-2004
[a private response was sent - which you neglected to note here]
[don't top post - it's rude]
[reformated message follows]

Mark J Fenbers <> wrote in message news:<>...
> James Willmore wrote:
>
> > On Mon, 01 Mar 2004 10:04:30 -0500, Mark J Fenbers wrote:
> >
> > > $^O gives the O/S name, in my case : 'linux', but I want to run my Perl script
> > > on RH 7.X and RH 9.x of Linux. How can my script determine which version of the
> > > O/S it is running on?

> >
> > Why should your script care about the distro of Linux?
> >
> > More importantly, why are you coding to a certain distro of Linux?
> > That a little like making tall kitchen garbage bags to fit only a certain
> > vendor's tall kitchen garbage can



> Well, because I have third-party software that I call from my script and that
> software has to be called with different environmental settings on RH 9 than it does
> for RH 7.


Keep your eye on the prize - the environment variables, not the OS.
If you code based upon the various distros of Linux, be prepared to
include some 50+ tests (one for each version of Red Hat, plus other
Linux distros). Red Hat is not the only distro out there (I use SuSE
and have tried others, including Red Hat).

My guess is you're looking for, maybe, a language setting? Or a
locale setting? If so, test for the settings, not the distro.

Just a side note - what happens when you get people like me who
*change* the environment settings for one reason or another. What
happens then? From your logic, if I use RH7, and the script sets up
"stuff" based upon the OS, your script *may* fail because I changed an
environment setting you're depending upon being set properly (because
it's that way for RH7 out of the box).

Give some thought to the above statements. Maybe this is all moot. I
just would *not* test based upon a Linux distro. Too many things can
go South real quick.

HTH

Jim
(jwillmore _at_ adelphia _dot_ net)
 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Where to get stand alone Dot Net Framework version 1.1, version2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? MowGreen [MVP] ASP .Net 5 02-09-2008 01:55 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? PA Bear [MS MVP] ASP .Net 0 02-05-2008 03:28 AM
Re: Where to get stand alone Dot Net Framework version 1.1, version 2.0, version 3.0, version 3.5, version 2.0 SP1, version 3.0 SP1 ? V Green ASP .Net 0 02-05-2008 02:45 AM
Why Petshop Changed all static methods to instance methods when upgrading from version 3.0 to version 3.1? Neo ASP .Net 1 01-07-2005 01:46 AM
Express Version Kills Current Version Lloyd Sheen ASP .Net 11 07-02-2004 02:45 PM



Advertisments