LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how are ksh Integer and expr translated into Bash? (https://www.linuxquestions.org/questions/linux-newbie-8/how-are-ksh-integer-and-expr-translated-into-bash-931014/)

zhegoofy 02-24-2012 03:55 AM

how are ksh Integer and expr translated into Bash?
 
Dears,

I am quite new to Linux Bash, but I have some experience in KSH. Currently I am trying to 'compile' one of my ksh scripts into Bash.

Most of the work has been done, but I am struggeling with the following ksh code:

integer status=$(expr ${exitstat[0]} + ${exitstat[1]})

I simply can't get this right on Linux. The exitstat are numbers which I want to add up. But for some reason I can't get this working. FYI: The status will be used in the following:

if [[ ${status} -eq 0 ]]
then
printf "\nORADBA-I-ODBUPX: The ${ORACLE_SID} database is ${status} up \c"
printf "(pcstatus=${status})\n"
exit ${CLEAN}
else
printf "\nORADBA-E-ODBDWN: The ${ORACLE_SID} database is ${status} down \c"
printf "(pcstatus=${status})\n"
exit ${EXIT1}
fi

Any help would be very much appreciated!
Thanks!

acid_kewpie 02-24-2012 04:39 AM

I think you just need "status=$((exitstat[0] + exitstat[1]))" as these are integers all the way through anyway by the look of it.

zhegoofy 02-24-2012 04:46 AM

This did the trick! You don't want to know how many hours I spend to get this result! ;)

Many thanks Acid_kewpie!


All times are GMT -5. The time now is 07:12 PM.