What is more detailled than $^O ?

Y

Yohan N Leder

I would like to distinguish the accurate linux distribution when $^O is
'linux'. How to do ? Do I have to figure-out searching for trace of
distribution name in some environment variables like SERVER_SOFTWARE or
SERVER_SIGNATURE which may contains a reference to the operating system
under which the web server has been built for ? Something better in mind
?
 
A

anno4000

Yohan N Leder said:
I would like to distinguish the accurate linux distribution when $^O is
'linux'. How to do ? Do I have to figure-out searching for trace of
distribution name in some environment variables like SERVER_SOFTWARE or
SERVER_SIGNATURE which may contains a reference to the operating system
under which the web server has been built for ? Something better in mind
?

Look for the standard module Config (perldoc Config).

Anno
 
Y

Yohan N Leder

What is the "accurate linux distribution" anyway?

At least something saying Red Hat, Fedora, Debian, Ubuntu, Suse, etc.
And better if it say also the major version number.
 
T

Ted Zlatanov

At least something saying Red Hat, Fedora, Debian, Ubuntu, Suse, etc.
And better if it say also the major version number.

In non-Perl terms, this information is often in /etc. The file
/etc/issue in particular is often useful.

It's almost always better to test for tools and features than
distributions anyhow. If you need package X, don't assume it's
installed, check. For a web server, Apache for example, there's tools
to tell you the version and compiled-in or loaded features. Perl
can't solve this problem in general terms AFAIK.

Ted
 
E

Eric Schwartz

Abigail said:
Yohan N Leder ([email protected]) wrote on MMMMDCCCXV September MCMXCIII in
__ (e-mail address removed) says...
__ > What is the "accurate linux distribution" anyway?
__ >
__
__ At least something saying Red Hat, Fedora, Debian, Ubuntu, Suse, etc.
__ And better if it say also the major version number.


Then what? Just because it's Red Hat doesn't mean it has package X,
and just it's Debian doesn't mean it doesn't have package X.

If one is writing an installer, it might be useful to know if one is
to use yum, apt-get, or yast to install any dependencies, or which
package to prompt the user to install. If one is writing a test
harness, it's often useful to be able to report to the person reading
the test results what distro was installed on the system under test.
If you want to test for a specific feature, test for that feature.
Don't assume that a specific Linux distro means something is available
(or not available).

Generally I agree with you, and I wish more programs behaved that way,
but there are times it's simply not sufficient.

-=Eric
 
Y

Yohan N Leder

In non-Perl terms, this information is often in /etc. The file
/etc/issue in particular is often useful.

It's almost always better to test for tools and features than
distributions anyhow. If you need package X, don't assume it's
installed, check. For a web server, Apache for example, there's tools
to tell you the version and compiled-in or loaded features. Perl
can't solve this problem in general terms AFAIK.

Yes, but I don't want to test what feature is available or not. The fact
is that some of the Perl CGI scripts we spread in our intranet and
extranet have to proceed with reports from proprietaries logs in
different trees depending of the specific linux distribution (actually :
Ubuntu, Debian, Red Hat Ent, Fedora and Suse, but more in future).

Also, some of these logs may have different signification depending of
the current distribution (so, we can't simply check for file presence
and deduct it's this or this distribution).

And, to facilitate the stuff, some of the servers may change from time
to time (I mean, change of linux ditribution from multi-boot or raw
change) and every admin has choice to keep of strip-out some parts of
the logs tree I told about ; this without notice, so I can't maintain a
simple database saying server #1 is under Debian, server #2 is under
Fedora, etc.

Well, because of this specific context, I have to determinate what is
the current linux ditribution (at least the 'main name' as said above,
even if I can't know the version) up front of all. Never mind what are
the available features or installed packages, it's not the information
I'm looking for and our packages will run whatever be the config.
 
Y

Yohan N Leder

Then what? Just because it's Red Hat doesn't mean it has package X,
and just it's Debian doesn't mean it doesn't have package X.

Same reply as the one written for Ted :

Yes, but I don't want to test what feature is available or not. The fact
is that some of the Perl CGI scripts we spread in our intranet and
extranet have to proceed with reports from proprietaries logs in
different trees depending of the specific linux distribution (actually :
Ubuntu, Debian, Red Hat Ent, Fedora and Suse, but more in future).

Also, some of these logs may have different signification depending of
the current distribution (so, we can't simply check for file presence
and deduct it's this or this distribution).

And, to facilitate the stuff, some of the servers may change from time
to time (I mean, change of linux ditribution from multi-boot or raw
change) and every admin has choice to keep of strip-out some parts of
the logs tree I told about ; this without notice, so I can't maintain a
simple database saying server #1 is under Debian, server #2 is under
Fedora, etc.

Well, because of this specific context, I have to determinate what is
the current linux ditribution (at least the 'main name' as said above,
even if I can't know the version) up front of all. Never mind what are
the available features or installed packages, it's not the information
I'm looking for and our packages will run whatever be the config.
 
T

Ted Zlatanov

Yes, but I don't want to test what feature is available or not.

Well then that's too bad for you :) You can't just decide that
reality should suit you. Either you test for the features you want,
or you write unreliable code. Anyhow, what you are saying below leads
me to believe you don't really need to know about OS features.
The fact is that some of the Perl CGI scripts we spread in our
intranet and extranet have to proceed with reports from
proprietaries logs in different trees depending of the specific
linux distribution (actually : Ubuntu, Debian, Red Hat Ent, Fedora
and Suse, but more in future).
Also, some of these logs may have different signification depending of
the current distribution (so, we can't simply check for file presence
and deduct it's this or this distribution).
And, to facilitate the stuff, some of the servers may change from time
to time (I mean, change of linux ditribution from multi-boot or raw
change) and every admin has choice to keep of strip-out some parts of
the logs tree I told about ; this without notice, so I can't maintain a
simple database saying server #1 is under Debian, server #2 is under
Fedora, etc.

Well, because of this specific context, I have to determinate what is
the current linux ditribution (at least the 'main name' as said above,
even if I can't know the version) up front of all. Never mind what are
the available features or installed packages, it's not the information
I'm looking for and our packages will run whatever be the config.

Sounds like you just need to look in a few places, examine the first
few lines of the log files, and determine whether to process them in
mode A or B or C etc. It doesn't seem to be about recognizing the OS,
but about detecting log files in several locations and finding the
formats. Am I missing something? Is it ever the case that you may
mistakenly use mode B when mode A was needed if you use this approach?
I would expect this to be more reliable than OS detection, too,
because you are actually checking for job prerequisites rather than
guessing based on the OS.

Ted
 
Y

Yohan N Leder

Well then that's too bad for you :) You can't just decide that
reality should suit you. Either you test for the features you want,
or you write unreliable code. Anyhow, what you are saying below leads
me to believe you don't really need to know about OS features.

You surely know the sentence : "Tell me what you need and I'll tell you
how to do without"... Really and independently to the kindly of your
post, I'll don't debate about the pertinence or not of the choice, but
how to achieve this precise choice : I'm not alone here, but just the
one who has to achieve this specific choice these days... So, I'll do it
whatever be the way to succeed... And I'll do it because I know how it
works in our team : sometimes, some work on stuff which are not directly
useful to their own job but on a direction which will be more efficient
for the global structure/projects : in others words, even if in my own
current little case I could do otherwise, it would be not a good choice
just because this decision to write something which detect the "linux
distribution" has been choosen by a team, keeping in mind what could be
useful a day or another to the others in this same team (a matter of
middle term approach).

So, my question remains the same : how to check what's the current linux
distribution from a cgi Perl script ? Say, to begin and to point a
concrete case : how to distinguish if a linux is a Debian/Ubuntu or a
RedHat/Fedora ?
 
C

Charlton Wilbur

Yohan N Leder said:
You surely know the sentence : "Tell me what you need and I'll tell you
how to do without"... Really and independently to the kindly of your
post, I'll don't debate about the pertinence or not of the choice, but
how to achieve this precise choice :

There's a concept known as the XY problem. The querent asks "How do I
do Y?" In reality, he's interested in knowing how to X, and he's
convinced that doing Y is the best way to do X. Such a querent is
almost always wrong.

In this case, you want to know if it's Debian or Fedora so you know
where to look for the log files and what format to expect the log
files in. There's no built-in pre-existing way to find out what
distribution you're on; so look for the log files in both places and
parse them according to the format you'd expect them to be if they
were there. Problem solved.

Charlton
 
Y

Yohan N Leder

In this case, you want to know if it's Debian or Fedora so you know
where to look for the log files and what format to expect the log
files in. There's no built-in pre-existing way to find out what
distribution you're on; so look for the log files in both places and
parse them according to the format you'd expect them to be if they
were there. Problem solved.

You don't understand the concept of a team here. Imagine (just a
scenario from a lot of possibles) this :

Now : I have to guess what the logs and trees are : so, what you say is
correct : I could just check and try these logs and tress.

In two weeks : Philip (a friend of mine in the team) has to auto-
generate a report from a Perl CGI script which just write the exact
linux ditribution in the subtitle of every report : unfortunately he
can't re-use what I've done because I'm a well known selfish.

Maybe more, I can't add in my own task myself because I need he finish
his own.

One week later : Samantha (yeah), collect the Philip's reports of the
last week and try to establish some statistics based on specific linux
distributions indicated on every report. Also, she wants (and when
Samantha wants, you can imagine...) to compare these statistics about a
week against the current states (close to "realtime") of the servers
park, reusing, again, the same piece of Perl code I've written (and
which has been modified, maybe, by Philip) tree weeks ago.

More, because she is a consultant, we've kept some money which will have
more chance to go in Philip and mine's pockets (oh, no!, big boss is
watching us ;-))

Well, so I don't target Y ignoring X without valid reason but because of
long experience in the concept of team !

Well, this said, I've found a begin of answer some minutes ago :
http://search.cpan.org/~kerberus/Linux-Distribution-
0.14/lib/Linux/Distribution.pm
 
C

Charlton Wilbur

Yohan N Leder said:
More, because she is a consultant, we've kept some money which will have
more chance to go in Philip and mine's pockets (oh, no!, big boss is
watching us ;-))

Well, so I don't target Y ignoring X without valid reason but because of
long experience in the concept of team !

In other words, you're writing code now that you think may be useful
later. Why not just solve your own problem as simply and clearly as
possible, and let Philip and Samantha worry about hypothetical
problems when they're no longer hypothetical?

http://en.wikipedia.org/wiki/You_Ain't_Gonna_Need_It

You've still got an XY problem, you're just hell-bent on doing it that
way because you think it may be useful someday.

Charlton
 
Y

Yohan N Leder

In other words, you're writing code now that you think may be useful
later. Why not just solve your own problem as simply and clearly as
possible, and let Philip and Samantha worry about hypothetical
problems when they're no longer hypothetical?

http://en.wikipedia.org/wiki/You_Ain't_Gonna_Need_It

You've still got an XY problem, you're just hell-bent on doing it that
way because you think it may be useful someday.

Neither "may be useful later" nor "may be useful someday" or
"hypothetical", but because I know it will be useful in some weeks...
And because my current charge of work is under the Philip's one these
days... Again, a matter of team in a long term collaboration (this
method work successfully for us since ten years now ; in others fields
than Perl).

Remember that the universality doesn't exist : whatever be the wiki
philosophy you could link to, there will be always the reverse somewhere
and both may work for some and not the others...
 
Y

Yohan N Leder

Yohan N Leder ([email protected]) wrote on MMMMDCCCXVI September MCMXCIII
in <URL:-:
-: So, my question remains the same : how to check what's the current linux
-: distribution from a cgi Perl script ? Say, to begin and to point a
-: concrete case : how to distinguish if a linux is a Debian/Ubuntu or a
-: RedHat/Fedora ?


Why don't you ask this in the Python group, and report back how they
do it. Then we'll translate the Python code to Perl code....

This isn't really a Perl question, is it?


Abigail

If you've read the thread, you've seen it's solved now
 
A

anno4000

Yohan N Leder said:
It's your second post in a thread which is not a Perl one : you're very
strong in "non sequitur" too

Oh man. "Non sequitur" means your logic was flawed. It has nothing
to do with being off topic.

As a regular who has posted thousands of postings *with* Perl content
I can afford the occasional off topic posting.

Anno
 
Y

Yohan N Leder

Is this the item in the thread that you later claimed is your solution to
your non-Perl problem?

Not my solution, a solution. However, I started from $^O, remember.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,660
Latest member
vidotip479

Latest Threads

Top