function joey_read_value
{
if [ $# -ne 1 ]; then
joey_wrong_log "***Exit joey_read_value"
exit 1
fi
typeset joey_local_key=$1
if [ ! -f ${joey_config_file_name} ];then
joey_wrong_log "The config file not a file.config file is:${joey_config_file_name}"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
fi
####
typeset joey_local_count=`cat ${joey_config_file_name}|awk -F= -v k="${joey_local_key}" '{ if ( $1 == k ) print $2 }'|wc -l`
if [ ${joey_local_count} -ge 2 ];then
joey_wrong_log "There are two same key in the config file.So the config wrong!"
joey_wrong_log "The key is :${joey_local_key}"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
fi
if [ ${joey_local_count} -eq 1 ];then
typeset joey_local_value=`cat ${joey_config_file_name}|awk -F= -v k="${joey_local_key}" '{ if ( $1 == k ) print substr($0,(length($1)+2),length($0)) }'`
if [ $? -ne 0 ];then
joey_wrong_log "read the key in config Failed!Key:${joey_local_key}"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
else
if [ "X${joey_local_value}" = "X" ];then
joey_wrong_log "read the key in config ,the key value is null!Key:${joey_local_key}"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
else
joey_return=${joey_local_value}
return 0
fi
fi
else
joey_wrong_log "Can't find the value of the specified key \"${joey_local_key}\"!"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
fi
}
{
if [ $# -ne 1 ]; then
joey_wrong_log "***Exit joey_read_value"
exit 1
fi
typeset joey_local_key=$1
if [ ! -f ${joey_config_file_name} ];then
joey_wrong_log "The config file not a file.config file is:${joey_config_file_name}"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
fi
####
typeset joey_local_count=`cat ${joey_config_file_name}|awk -F= -v k="${joey_local_key}" '{ if ( $1 == k ) print $2 }'|wc -l`
if [ ${joey_local_count} -ge 2 ];then
joey_wrong_log "There are two same key in the config file.So the config wrong!"
joey_wrong_log "The key is :${joey_local_key}"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
fi
if [ ${joey_local_count} -eq 1 ];then
typeset joey_local_value=`cat ${joey_config_file_name}|awk -F= -v k="${joey_local_key}" '{ if ( $1 == k ) print substr($0,(length($1)+2),length($0)) }'`
if [ $? -ne 0 ];then
joey_wrong_log "read the key in config Failed!Key:${joey_local_key}"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
else
if [ "X${joey_local_value}" = "X" ];then
joey_wrong_log "read the key in config ,the key value is null!Key:${joey_local_key}"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
else
joey_return=${joey_local_value}
return 0
fi
fi
else
joey_wrong_log "Can't find the value of the specified key \"${joey_local_key}\"!"
echo "some thing wrong in easy_work.see the log:${joey_log_file}"
exit 1
fi
}