Hi,
I've the following script, that reads a set of parameters from a .conf
file and load it into vars... it works OK on my Debian Box but... It
just produces no answer on BusyBox with the exception of a blank line
for each "echo" in the script...
So I'm thinking about it doesn't put values on the vars (that's why it
produces blank echo lines...)
Anybody knows what can be going wrong? Something could be different on
BB? I looks alright to me!
Thanks a lot!!
------
#!/bin/bash
# Function: get_config_list config_file
# Purpose : Print the list of configs from config file
get_config_list()
{
typeset config_file=$1
awk -F '[][]' '
NF==3 && $0 ~ /^\[.*\]/ { print $2 }
' ${config_file}
}
# Function : set_config_vars config_file config [var_prefix]
# Purpose : Set variables (optionaly prefixed by var_prefix) from
config in config file
set_config_vars()
{
typeset config_file=$1
typeset config=$2
typeset var_prefix=$3
typeset config_vars
config_vars=$(
awk -F= -v Config="${config}" -v Prefix="${var_prefix}" '
BEGIN {
Config = toupper(Config);
patternConfig = "\\[" Config "]";
}
toupper($0) ~ patternConfig,(/\[/ && toupper($0) !~
patternConfig) {
if (/\[/ || NF <2) next;
sub(/^[[:space:]]*/, "");
sub(/[[:space:]]*=[[:space:]]/, "=");
print Prefix $0;
} ' ${config_file} )
eval "${config_vars}"
}
#
# Set variables for all config from config file
#
file=BlackBox.conf
for cfg in $(get_config_list ${file})
do
echo "--- Configuration [${cfg}] ---"
unset $(set | awk -F= '/^cfg_/ { print $1 }') cfg_
set_config_vars ${file} ${cfg} cfg_
set | grep ^cfg_
done
echo $cfg_WIFI #Testing boolean wifi value
echo $cfg_NTP_Server # Testing value for NTP Server IP
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox