On Fri, 8 Apr 2005, D. J. Birkett wrote: > I'm writing a script that will be run from a mount point on many > different linux distros. I'm just about to code a sub that will try > and determine the distro (version isn't that important) from the > /etc/*release file, and just wondered if anyone has already done this, > or if there is some handy util that I don't know about that will do it > for me? >From the what file ?
The only Linux I have access to at the moment is Debian, but neither it nor OSX (which, admittedly, isn't Linux) has any /etc/*elease* files. For that matter... [EMAIL PROTECTED] ~]# find /etc -type f | grep -i elease [EMAIL PROTECTED] ~]# So that pattern doesn't show up *anywhere* under /etc on Debian. This might be useful though: [EMAIL PROTECTED] ~]$ cat /etc/debian_version 3.0 [EMAIL PROTECTED] ~]$ This (currently) corresponds to Debian Stable. You may possibly have better luck with `uname -a`, which is portable: [EMAIL PROTECTED] ~]$ uname -a Linux debian 2.4.26-smp-p4 #1 SMP Thu Apr 29 17:20:05 EDT 2004 i686 unknown [EMAIL PROTECTED] ~]$ [EMAIL PROTECTED] ~]$ uname -a Darwin osx 7.8.0 Darwin Kernel Version 7.8.0: Wed Dec 22 14:26:17 PST 2004; root:xnu/xnu-517.11.1.obj~1/RELEASE_PPC Power Macintosh powerpc [EMAIL PROTECTED] ~]$ (And that should work on other Linux distros, Solaris, BSD, Irix, etc.) But the real question is what are you trying to do that is dependendant on the Linux distribution? The path you're on now implies that you're going to build up some kidn of database of what functionality is available on which platforms, and respond accordingly. This is not a very easy approach to maintain -- it's exactly the same wrong approach that makes browser handling such a pain in most Javascript code. You may find that a *much* easier approach is to just go ahead and do what you intend to do, perhaps in an eval{} block, and if something goes wrong, *then* try to handle the error and make a note of what platform you were on when things went wrong. In that way, you can automatically build up a list of what platforms are causing problems and find ways to handle them as needed. As a rule of thumb, I suspect that this kind of "just do it and note the environment if things blow up" approach will be much more robust than a "identify the platform, then try based on the platform detection, then handle any problems" approach. But YMMV of course :-) -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>