LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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, 03: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, 04:39 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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, 04: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 12:45 AM
[SOLVED] ksh-20100202-1.el5 integer typeset issue adb101 Linux - Software 1 07-29-2011 08: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 05:31 PM
Bash vs ksh Nickbrandson Linux - Newbie 7 04-23-2008 06:40 PM
bash or ksh noir911 *BSD 5 05-10-2007 11:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:46 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
Open Source Consulting | Domain Registration