Linux distribution recognize/de: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: Linux distribution recognize/de
| Old | New | Line | |
|---|---|---|---|
| 1 | + | Zurück zur Seite [[code examples/de|Code Beispiele]]. | |
| 2 | + | ||
| 3 | + | Dieser Artikel beschäftigt sich mit der Linuxprogrammierung. | |
| 4 | + | ||
| 5 | + | Die Prozedur ermittelt den Namen der aktuellen Linuxdistribution. | |
| 6 | + | ||
| 7 | + | ``` pascal | |
| 8 | + | uses | |
| 9 | + | SysUtils, ...; | |
| 10 | + | ||
| 11 | + | ... | |
| 12 | + | ||
| 13 | + | function funLeseDatei: string; | |
| 14 | + | var | |
| 15 | + | txtDatei: Textfile; | |
| 16 | + | begin | |
| 17 | + | Assignfile(txtDatei, '/etc/issue'); // weist txtDatei die Datei zu | |
| 18 | + | reset(txtDatei); // oeffnet die Datei zum lesen | |
| 19 | + | readln(txtDatei, Result); // liest die erste Zeile | |
| 20 | + | Closefile(txtDatei); // schliesst die Datei | |
| 21 | + | end; | |
| 22 | + | ||
| 23 | + | function funLinuxDistribution: string; | |
| 24 | + | var | |
| 25 | + | strDistribution: string; | |
| 26 | + | ||
| 27 | + | begin | |
| 28 | + | ||
| 29 | + | Result := ''; | |
| 30 | + | ||
| 31 | + | strDistribution := funLeseDatei; | |
| 32 | + | if strDistribution = '' then | |
| 33 | + | exit; | |
| 34 | + | ||
| 35 | + | // Wandelt alle Grossbuchstaben in Kleinbuchstaben um | |
| 36 | + | strDistribution := LowerCase(strDistribution); | |
| 37 | + | ||
| 38 | + | // ermittelt die Distribution | |
| 39 | + | if Pos('debian', strDistribution) > 0 then | |
| 40 | + | Result := 'debian' | |
| 41 | + | else if Pos('kubuntu', strDistribution) > 0 then | |
| 42 | + | Result := 'kubuntu' | |
| 43 | + | else if Pos('red hat', strDistribution) > 0 then | |
| 44 | + | Result := 'red hat' | |
| 45 | + | else if Pos('suse', strDistribution) > 0 then | |
| 46 | + | Result := 'suse' | |
| 47 | + | else if Pos('ubuntu', strDistribution) > 0 then | |
| 48 | + | Result := 'ubuntu'; | |
| 49 | + | // .. und der Distributionen mehr ... | |
| 50 | + | ||
| 51 | + | end; | |
| 52 | + | ||
| 53 | + | ... | |
| 54 | + | ||
| 55 | + | ``` | |
| 56 | + | ||
| 57 | + | Auf Systemen, die dem [Linux Standard Base](https://www.linuxbase.org/) Standard folgen, kann die Datei `/etc/lsb-release` ausgelesen werden. | |
| 58 | + | ||
| 59 | + | --- | |
| 60 | + | *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](/wiki-contact).* |
