Forum > Linux

[Solved] Differentiate between various Linux distros

(1/5) > >>

petevick:
At the moment in my project I differentiate between Linux and Windows by this code....

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{ TForm1 }function OSVersion: String;begin  {$IFDEF Linux}  OSVersion := 'Linux';  {$ELSE}  {$IFDEF WINDOWS}  OSVersion := 'Windows';  {$ENDIF}  {$ENDIF}end; ...but is there a way to differentiate between other Linux/Ubuntu distros, say Linux Mint and Kubuntu.

petevick:
Hmmm, maybe I just expand on what I have, something like.....


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---{ TForm1 }function OSVersion: String;begin  {$IFDEF Linux}  OSVersion := 'Linux';  {$ELSE}  {$IFDEF Ubuntu}  OSVersion := 'Ubuntu';  {$ELSE}  {$IFDEF WINDOWS}  OSVersion := 'Windows';  {$ENDIF}  {$ENDIF}  {$ENDIF}end;

petevick:
Nope, that doesn't work  %)

Lutz Mändle:
Have a look at /etc/os-release, there is also a man page (man os-release).

howardpc:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  FileUtil; function GetLinuxDistro: String;const  Issue = '/etc/issue';begin  case FileExists(Issue) of    True:  Result := ReadFileToString(Issue);    False: Result := 'unknown distro';  end;end;       

Navigation

[0] Message Index

[#] Next page

Go to full version