To find out what distro I'm on I've always written ad-hoc code that looked for some distribution-specific feature, like /etc/redhat-release and, if necessary, parsed the output.
Now, the Linux Standards Base has a command that'll do the job for me.
$ lsb_release -a 2>/dev/null(There's an error message saying "No LSB modules are available." on this distro, which I'm discarding.)
Distributor ID: Ubuntu
Description: Ubuntu 7.10
Release: 7.10
Codename: gutsy
This is roughly analogous to "uname -a", but about the distro, not the box.
$ uname -aIt lets me sequester distro-specific actions in code like this:
Linux jsh-laptop 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux
case $(lsb_release -i 2>/dev/null) inOld pal, Nick Stoughton, our Usenix Standards Rep, points me at the relevant standard, here.
*Ubuntu*) echo This is Ubuntu ;;
*) echo This is NOT Ubuntu ;;
esac
No comments:
Post a Comment