LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-24-2012, 04:55 AM   #1
zhegoofy
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Rep: Reputation: Disabled
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!
 
Old 02-24-2012, 05:39 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
I think you just need "status=$((exitstat[0] + exitstat[1]))" as these are integers all the way through anyway by the look of it.
 
Old 02-24-2012, 05:46 AM   #3
zhegoofy
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
This did the trick! You don't want to know how many hours I spend to get this result!

Many thanks Acid_kewpie!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Test for integer in BASH minil Programming 18 02-01-2012 01:45 AM
[SOLVED] ksh-20100202-1.el5 integer typeset issue adb101 Linux - Software 1 07-29-2011 09:21 AM
How to multiply with expr? ( expr 3 * 4 doesn't work, though expr 3 + 4 does) lumix Linux - General 5 02-25-2009 06:31 PM
Bash vs ksh Nickbrandson Linux - Newbie 7 04-23-2008 07:40 PM
bash or ksh noir911 *BSD 5 05-10-2007 12:08 PM


All times are GMT -5. The time now is 08:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration