Linux distribution recognize/de
Zurück zur Seite Code Beispiele.
Dieser Artikel beschäftigt sich mit der Linuxprogrammierung.
Die Prozedur ermittelt den Namen der aktuellen Linuxdistribution.
uses
SysUtils, ...;
...
function funLeseDatei: string;
var
txtDatei: Textfile;
begin
Assignfile(txtDatei, '/etc/issue'); // weist txtDatei die Datei zu
reset(txtDatei); // oeffnet die Datei zum lesen
readln(txtDatei, Result); // liest die erste Zeile
Closefile(txtDatei); // schliesst die Datei
end;
function funLinuxDistribution: string;
var
strDistribution: string;
begin
Result := '';
strDistribution := funLeseDatei;
if strDistribution = '' then
exit;
// Wandelt alle Grossbuchstaben in Kleinbuchstaben um
strDistribution := LowerCase(strDistribution);
// ermittelt die Distribution
if Pos('debian', strDistribution) > 0 then
Result := 'debian'
else if Pos('kubuntu', strDistribution) > 0 then
Result := 'kubuntu'
else if Pos('red hat', strDistribution) > 0 then
Result := 'red hat'
else if Pos('suse', strDistribution) > 0 then
Result := 'suse'
else if Pos('ubuntu', strDistribution) > 0 then
Result := 'ubuntu';
// .. und der Distributionen mehr ...
end;
...Auf Systemen, die dem Linux Standard Base Standard folgen, kann die Datei /etc/lsb-release ausgelesen werden.
From the Free Pascal wiki, page "Linux distribution recognize/de", as it stood on 2020-02-19 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.
Talk about this page
Nobody has opened a bench for this page yet. Sign in to open one.
