I am having a problem with an example script that is given in the textbook 'Unix and System Administration Handbook'. The script is below... I am receiving an error that states logscript: line 8: [: 1: unary operator expected.
# The log level is set in the global variable LOG_LEVEL. The choices
# are, from most to least severe. Error, Warning, Info, and Debug.
function logMsg {
message_level=$1
message_itself=$2
if [ $message_level -le $LOG_LEVEL ]; then
case $message_level in
0) message_level_text="Error";;
1) message_level_text="Warning";;
2) message_level_text="Info";;
3)message_level_text="Debug";;
*) message_level_text="Other"
esac
echo "${message_level_text}: $message_itself"
fi
}
# Main program starts here
logMsg $1 $2
Any ideas as to why this error is showing up?
Aucun commentaire:
Enregistrer un commentaire