Hi Again Guru's
One of the requirements for the shell script is that when the return value of a given function is not equal to zero, it should have the option for the user to re-execute the function that has failed.
Example:
the script has different functions:
func_1()
func_2()
func_3()
func_4()
....
when func_1 fails, it should ask the user to make some necessrary corrections and once done, it should re-execute that same function.
Any idea will help.
below is the sample code.
#!/usr/bin/sh
#Function to get return value
func_getRetValue()
{
retValue=$?
if [ $retValue -gt 0 ]
then
echo "Encountered ERROR"
func_pause "Press any key when ready ..."
else
echo "NO ERROR FOUND"
func_pause "Press Any key to continue..."
fi
}
#function to wait for the user's prompt before proceeding
func_pause()
{
read -p "$*"
}
#Function to check if supplemental logging is enabled in Aexeo Database
func_enableSupplementalLoggingOnAexeoDB()
{
sqlplus -s ${userName}/${password}@//${hostname}/${oraInstance} <<EOF > ${logDir}/output.out
set heading off
SELECT SUPPLEMENTAL_LOG_DATA_MIN from v\$database;
EOF
#Check the output of the sql statement if it is "YES"
#if not run sql statemet to alter the table
status=`cat ${logDir}/output.out | sed '/^$/d' | tail -3`
if [ $status == "YES" ]
then
echo "Minimal supplemental logging is enabled in Aexeo Database"
echo "Status is ${status}"
elif [ $status != "YES" ]
then
echo "Supplemental logging is not enabled"
echo "Please login to Database and set SUPPLEMENTAL_LOG_DATA_MIN to \"YES\" "
fi
#func_pause "Once corrected press any key to continue ..."
}
func_createPartitionsVPDUsers()
{
}
#-----------------
# Main
#-----------------
step="${1:-0}"
while :
do
case $step in
0) : ;;
1) echo "Running Step 1 : Check supplemental logging in Aexeo Database is enabled"
func_enableSupplementalLoggingOnAexeoDB
retValue=$?
if [ $retValue -gt 0 ]
then
echo "Encountered ERROR"
func_pause "Press any key when ready ..."
else
echo "NO ERROR FOUND"
func_pause "Press Any key to continue..."
fi
;;
2) func_createPartitionsVPDUsers
;;
*) exit ;;
esac
((step=${step} + 1))
done