homelab importiert jetzt alle Server aus Mobaxterm Datei
This commit is contained in:
@@ -1,18 +1,28 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
rm serverliste.csv
|
||||||
|
wget http://fileserver.fritz.box/Mobaxterm/Homelab.mxtsessions
|
||||||
|
|
||||||
# Eingabedatei
|
# Eingabedatei
|
||||||
INPUT_FILE="Homelab.mxtsessions"
|
INPUT_FILE="Homelab.mxtsessions"
|
||||||
# Ausgabedatei
|
# Ausgabedatei
|
||||||
OUTPUT_FILE="serverliste.csv"
|
OUTPUT_FILE="serverliste.csv"
|
||||||
|
|
||||||
# Kopfzeile der CSV schreiben
|
# Kopfzeile der CSV-Datei
|
||||||
echo "Name,Adresse / Host" > "$OUTPUT_FILE"
|
echo "Name,Adresse / Host" > "$OUTPUT_FILE"
|
||||||
|
|
||||||
# Daten extrahieren und formatieren
|
# Alle Zeilen in Bookmarks-Abschnitten durchsuchen
|
||||||
grep -oP '^[^=]+=#109#0%[^%]+' "$INPUT_FILE" | while IFS= read -r line; do
|
awk '
|
||||||
name=$(echo "$line" | cut -d'=' -f1 | sed 's/.*\\n//')
|
/^\[Bookmarks/ { in_section=1; next }
|
||||||
host=$(echo "$line" | cut -d'%' -f2)
|
/^\[/ && !/^\[Bookmarks/ { in_section=0 }
|
||||||
echo "$name,$host" >> "$OUTPUT_FILE"
|
in_section && /=#109#0%/ {
|
||||||
done
|
split($0, parts, "=")
|
||||||
|
name = parts[1]
|
||||||
|
split(parts[2], details, "%")
|
||||||
|
host = details[2]
|
||||||
|
gsub(/.*\\n/, "", name)
|
||||||
|
print name "," host
|
||||||
|
}
|
||||||
|
' "$INPUT_FILE" >> "$OUTPUT_FILE"
|
||||||
|
|
||||||
echo "Export abgeschlossen: $OUTPUT_FILE"
|
echo "Export abgeschlossen: $OUTPUT_FILE"
|
||||||
|
|||||||
Reference in New Issue
Block a user