Bem, eu me afastei das declarações de caso para o egrep, pois isso parecia me ajudar. Eu tive problemas com a passagem de parâmetros para a minha função ... então eu apenas parei de fazer isso. Não é o melhor, mas eu tenho que trabalhar. Alguma outra opinião sobre isso?
#!/bin/ksh
#################################################################################
# PARAMETERS & VARIABLES SECTION #
#################################################################################
DBI_LOC="DBI/InstallCollector/dbi_collector/bin"
#Put input option to upper case.
OPTION=$( echo "$1" | tr "[:lower:]" "[:upper:]" )
#################################################################################
# FUNCTION SECTION #
#################################################################################
parseresults() {
if [ "${OPTION}" = "START" ] ; then
echo "Success"
return 0
else
echo ${RESULT} | egrep -s ".*DBI.*not\srunning.*"
if [ $? = 0 ] ; then
echo "Collector is already down. Continuing..."
return 0
fi
echo ${RESULT} | egrep -s ".*DBI.*COMPLETE.*"
if [ $? = 0 ] ; then
echo "Success shutting down collector. Continuing..."
return 0
fi
echo "Error shutting down the collector. Exiting with error."
return 1
fi
}
#################################################################################
# MAIN SCRIPT SECTION #
#################################################################################
case "${OPTION}" in
"START")
echo "Starting the collectors..."
RESULT=$(ksh ~/${DBI_LOC}/start_dbi_collector.sh)
;;
"STOP")
echo "Stopping the collectors..."
RESULT=$(ksh ~/${DBI_LOC}/stop_dbi_collector.sh)
;;
*)
echo "Error: No Parameter specified. Must be either start or stop"
exit 1
;;
esac
echo ${RESULT}
parseresults
if [ ! $? = 0 ] ; then
exit 1
fi
echo
echo