• 🏠 Accueil
  • 🧰 Générateurs
  • 📰 Blog
  • 🔎 Rechercher
  • 📧 Contact
  • 📘 Livre d'or
  • 🗞️ News
  • 💰 Soutien
  • Description

    This example shows how to open example2.cfg contiguration file, and read its contents.

    You have to create example2.cfg file, in cfg directory with those contents:

    ############################################################ 
    # File: example2.cfg                                       # 
    # Author: Jerome DESMOULINS - djeshellstepsATdesmoulins.fr # 
    # Description:                                             # 
    #   DjeShellSteps example 2: sample configuration file     # 
    ############################################################ 
    
    TmpDir=/tmp 
    [html]</pre>[/html] 
    [/block] 
    
    [title=1]example2.sh[/title] 
    [block] 
    [html]<pre class="brush: bash;">[/html] 
    #!/bin/bash 
    ############################################################ 
    # File: example2.sh                                        # 
    # Author: Jerome DESMOULINS - djeshellstepsATdesmoulins.fr # 
    # Description:                                             # 
    #   DjeShellSteps example 2: sample shell script           # 
    #   reading values from its configuration file             # 
    ############################################################ 
    
    ### Initialisation for environnement variables mandatory for DjeShellSteps ### 
    . `dirname $0`/djeshellsteps.sh 
    
    DjeOption_SummaryInfosToStdout=1 
    
    ### Beginning of Shell Script ### 
    BeginSteps 
    echo "Starting Shell Script..." 
    
    ########################################################### 
    Step 10 "Reading configuration file" 
    ########################################################### 
    if [ $RunThisStep -eq 1 ]; then 
      ReadConfigFile 
      sleep 2 
    fi 
    
    ########################################################### 
    Step 20 "Display variables from configuration file" 
    ########################################################### 
    if [ $RunThisStep -eq 1 ]; then 
      echo "TmpDir=$TmpDir" 
    fi 
    
    ### End of Shell Script ### 
    EndSteps 

    Retour



    (c) 2005-2025 Jérôme DESMOULINS
    Mentions légales