Quantcast
Channel: openSUSE Forums
Viewing all articles
Browse latest Browse all 40713

bash script code error on command output to varible

$
0
0
Code:

    #create LinuxScanFolders cfg file if not present
    if [[ -f "/var/log/VirusVault/scanvirus.cfg" ]]; then
        printf ""
    else
        printf "creating LinuxScanFolders\n"
        cat > /var/log/VirusVault/scanvirus.cfg <<EOL
__________scanvirus configuration__________
___________________________________________
Excluded Scan Folders
etc dev proc tmp mnt media srv .snapshots
___________________________________________
Time Date Stamp
date '+%Y-%m-%d %I:%M%P'
___________________________________________
EOL
    fi

    #setup configuration lines into array
    IFS=$'\n' read -d '' -r -a lines < /var/log/VirusVault/scanvirus.cfg

    printf "excluded folders: %s\n" "${lines[3]}"
    printf "time date stamp : %s\n" "${lines[6]}"
       
   
    Time_Date_Stamp=$( "${lines[6]}" )
    # check for date command error
    #if [[ $? != 0 ]]; then
    #    echo "----- Time_Date_Stamp error -----"
    #    exit 1
    #fi

    printf "%s\n" $Time_Date_Stamp

It checks for the config file. Creates it if needed. Then reads the file lines into an array. Assigns the time_date_stamp from a line in the file.

Code:

excluded folders: etc dev proc tmp mnt media srv .snapshots
time date stamp : date '+%Y-%m-%d %I:%M%P'
./scanvirusa: line 136: date '+%Y-%m-%d %I:%M%P': command not found

I can't find the error. Need help.

Viewing all articles
Browse latest Browse all 40713

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>