Re: If you're using linux can you run this command please?
- Posted by jmduro Sep 02, 2015
- 2248 views
Try this:
include std/filesys.e include std/text.e include std/sequence.e include std/io.e include std/search.e include myLibs/myDebug.e ------------------------------------------------------------------------------ function readFile(sequence filename) sequence s = read_lines(filename) sequence content = {} for i = 1 to length(s) do sequence line = trim(s[i]) if length(line)>0 then sequence t = split(line, '=') for j = 1 to length(t) do t[j] = dequote(trim(t[j])) end for content = append(content, t ) end if end for return content end function ------------------------------------------------------------------------------ function cat(sequence filename) sequence s = read_file(filename) return trim(s) end function ------------------------------------------------------------------------------ sequence s, short, long, release, description, name, version object o long = "" short = "" if file_exists("/etc/lsb-release") then s = readFile("/etc/lsb-release") o = vlookup("DISTRIB_RELEASE", s, 1, 2) if atom(o) then release = vlookup("DISTRIB_CODENAME", s, 1, 2) else release = o end if o = vlookup("DISTRIB_DESCRIPTION", s, 1, 2) if atom(o) then description = vlookup("DISTRIB_CODENAME", s, 1, 2) else description = o end if if length(description) then if length(release) then long = description & " (" & release & ")" else long = description end if end if o = vlookup("DISTRIB_ID", s, 1, 2) if atom(o) then short = "UnknownLSB" else short = match_replace(" ", o, "") end if else if file_exists("/etc/debian_version") then short = "Debian" s = readFile("/etc/os-release") name = vlookup("NAME", s, 1, 2) version = vlookup("VERSION", s, 1, 2) long = name & " " & version -- RPM derived distributions may also have a redhat-release or -- mandrake-release, so check their files first. elsif file_exists("/etc/altlinux-release") then short = "ALTLinux" long = cat("/etc/altlinux-release") elsif file_exists("/etc/magic-release") then short = "Magic" long = cat("/etc/magic-release") elsif file_exists("/etc/blackPanther-release") then short = "blackPanther" long = cat("/etc/blackPanther-release") elsif file_exists("/etc/ark-release") then short = "Ark" long = cat("/etc/ark-release") elsif file_exists("/etc/arch-release") then short = "Arch" long = cat("/etc/arch-release") elsif file_exists("/etc/asplinux-release") then short = "ASPLinux" long = cat("/etc/asplinux-release") elsif file_exists("/etc/lvr-release") then short = "LvR" long = cat("/etc/lvr-release") elsif file_exists("/etc/caos-release") then short = "cAos" long = cat("/etc/caos-release") elsif file_exists("/etc/aurox-release") then short = "Aurox" long = cat("/etc/aurox-release") elsif file_exists("/etc/engarde-release") then short = "EnGarde" long = cat("/etc/engarde-release") elsif file_exists("/etc/vine-release") then short = "Vine" long = cat("/etc/vine-release") elsif file_exists("/etc/whitebox-release") then short = "WhiteBox" long = cat("/etc/whitebox-release") elsif file_exists("/etc/pld-release") then short = "PLD" long = cat("/etc/pld-release") elsif file_exists("/etc/startcom-release") then short = "StartCom" long = cat("/etc/startcom-release") elsif file_exists("/etc/trustix-release") then short = "Trustix" long = cat("/etc/trustix-release") elsif file_exists("/etc/openna-release") then short = "OpenNA" long = cat("/etc/openna-release") elsif file_exists("/etc/conectiva-release") then short = "Conectiva" long = cat("/etc/conectiva-release") elsif file_exists("/etc/mandrake-release") then short = "Mandrake" long = cat("/etc/mandrake-release") elsif file_exists("/etc/fedora-release") then short = "Fedora" long = cat("/etc/fedora-release") elsif file_exists("/etc/redhat-release") then short = "RedHat" long = cat("/etc/redhat-release") elsif file_exists("/etc/SuSE-release") then short = "SuSE" if file_exists("/etc/SuSE-release") then long = cat("/etc/SuSE-release") else long = cat("/etc/SuSE-brand") end if elsif file_exists("/etc/gentoo-release") then short = "Gentoo" long = cat("/etc/gentoo-release") elsif file_exists("/etc/cobalt-release") then short = "Cobalt" long = cat("/etc/cobalt-release") elsif file_exists("/etc/yellowdog-release") then short = "YellowDog" long = cat("/etc/yellowdog-release") elsif file_exists("/etc/turbolinux-release") then short = "Turbolinux" long = cat("/etc/turbolinux-release") elsif file_exists("/etc/pardus-release") then short = "Pardus" long = cat("/etc/pardus-release") elsif file_exists("/etc/kanotix-version") then short = "Kanotix" long = cat("/etc/kanotix-version") elsif file_exists("/etc/slackware-version") then short = "Slackware" long = cat("/etc/slackware-version") elsif file_exists("/sbin/pkgtool") then short = "Slackware" long="Slackware Linux" elsif match("OpenLinux", "/etc/issue") then short = "Caldera" long="Caldera OpenLinux" elsif file_exists("/etc/frugalware-release") then short = "Frugalware Linux" long = cat("/etc/frugalware-release") elsif file_exists("/etc/kdemar-release") then short = "K-DEMar" long = cat("/etc/kdemar-release") elsif file_exists("/etc/lfs-release") then --Linux From Scratch short = "LFS" long = cat("/etc/lfs-release") elsif file_exists("/etc/meego-release") then short = "MeeGo" long = cat("/etc/meego-release") else short = "Linux" long = "unknown Linux distribution" end if end if puts(1, "Short name = " & short & "\n") puts(1, "Long name = " & long & "\n")
It has not been tested on all those distributions, so if people could try it and share results, it would be fine.
Here is for Linux Mint 17.2 Rafaela:
Short name = LinuxMint Long name = Linux Mint 17.2 Rafaela (17.2)
and for Fedora 22
Short name = Fedora Long name = Fedora release 22 (Twenty Two)