ryanW
April 20, 2009, 4:00am
1
Hi Everyone,
How to assign the specific value which return from database?
here is the return value from database -->
(return status = 0)
0 <----- this
I only need to get the "0" .. assign to another declare variable.
hope someone will help me..
Please
thank you..
Not sure what the problem is here...
Why can't you do something like rc=$? after you do whatever it is you are trying to do then check, if [[ $rc -eq 0 ]]; then ... fi
ryanW
April 20, 2009, 9:09pm
3
Hi,
For example, the return value from database is
data->> (return status = 0)
0
but i just wan to get "0" to assign into another new declaration.
if i do like this : rc=$data
rc will still get (return status = 0)
0
i just wan to get the specific "0", remove the others.
Thank you
Not sure if I understand totally but I think you want the '0' after the words "return status = "? Maybe this will give you some direction...
Assuming data="(return status = 0)"
rc=`echo $data|cut -d"=" -f2|cut -c1-2`
echo data=$data
echo $rc
----
output:
data=(return status = 0)
0
ryanW
April 20, 2009, 10:20pm
5
Thank you giannicello... the way u teach me is working fine... but i did change a bit,
Thank you so much....
The command show below is the way i changed... coz some return value is -1 or -2 or 0, and i have to get the number value is outside the branket... Thank you so much..
rc=`echo $result|cut -d")" -f2|cut -c1-3|cut -d" " -f2`
rc=-1
done...