[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Konfigurationsdatei mit confget einlesen, Datei enthält aber Variablen



Hallo liebe Liste,

ich habe eine Konfigurationsdatei ("datei.ini") mit folgendem Inhalt (nur ein Beispiel):

     [thilo]
          .....
          foo=/home/samba/thilo
          bar=/root/data/thilo
          .....
          .....

Die einzelnen Variablen kann ich problemlos mit dem Tool "confget" auslesen:

     # confget -f datei.ini -s thilo bar
     /root/data/thilo

So weit, so gut.

Nun möchte ich aber gerne erreichen, dass der oben genannte Befehl aus einem bash-script aufgerufen wird. In dem bash-script ist bereits eine Variable "BASISVERZEICHNIS" mit dem Wert "/root/data" definiert. Aus diesem Grund wäre optimal (aus Gründen der Übersichtlichkeit), wenn ich meine Konfigurationsdatei folgenden Aufbau hätte:

     [thilo]
          .....
          foo=/home/samba/thilo
          bar=$BASISVERZEICHNIS/thilo
          .....
          .....


Test auf der Kommandozeile:

     # BASISVERZEICHNIS="/root/data"
     # echo $BASISVERZEICHNIS
     /root/data

     # confget -f datei.ini -s thilo bar
     $BASISVERZEICHNIS/thilo

     # BAR=$(confget -f datei.ini -s thilo bar)
     # echo $BAR
     # $BASISVERZEICHNIS/thilo


Auch die Definition mit geschweiften Klammern funktioniert nicht:

     [thilo]
          .....
          foo=/home/samba/thilo
          bar=${BASISVERZEICHNIS}/thilo
          .....
          .....

     # BASISVERZEICHNIS="/root/data"
     # echo $BASISVERZEICHNIS
     /root/data

     # BAR=$(confget -f datei.ini -s thilo bar)
     # echo $BAR
     # ${BASISVERZEICHNIS}/thilo


Hat jemand von Euch eine Idee, wie man es schafft, dass $BASISVERZEICHNIS durch den entsprechenden Wert ersetzt wird?


Danke und Grüße,

Thilo


Reply to: