The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to replace a specific word in specific column? ./hari.sh Shell Programming and Scripting 6 03-07-2009 09:33 AM
how to display specific lines of a specific file raidkridley UNIX for Dummies Questions & Answers 2 10-15-2008 03:46 PM
Copying specific files from remote m/c to specific folders jhoomsharabi Shell Programming and Scripting 0 06-12-2008 08:31 AM
Assign variables with cut douknownam Shell Programming and Scripting 2 09-27-2004 10:18 AM
Assign a process to specific CPU tforveil UNIX for Dummies Questions & Answers 8 12-23-2003 05:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 3.00 average. Display Modes
  #1 (permalink)  
Old 04-20-2009
ryanW ryanW is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 34
How to assign the specific value

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..
  #2 (permalink)  
Old 04-20-2009
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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
  #3 (permalink)  
Old 04-20-2009
ryanW ryanW is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 34
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
  #4 (permalink)  
Old 04-20-2009
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
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
  #5 (permalink)  
Old 04-20-2009
ryanW ryanW is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 34
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...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:20 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0