User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,446 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,659 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 701 | Replies: 1
Reply
Join Date: Sep 2007
Posts: 3
Reputation: achilleus is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
achilleus achilleus is offline Offline
Newbie Poster

How to access parameters from another method in the same script

  #1  
Nov 1st, 2007
consider two methods in a script as below,

do_a()
{
spool $file1
select column1 from table1;
}

do_b()
{
spool $file2
select column1 from table2 where column2='xxxxx'
}

The first method returns just one value say 10001,I have to use this result in the second method in place xxxxx.
I used to call the method as

do_a >> ${outfile}
do_b >> ${outfile}

tell me how to get the arguments from method1 and pass it to method2.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Posts: 306
Reputation: eggi is on a distinguished road 
Rep Power: 2
Solved Threads: 29
eggi eggi is offline Offline
Posting Whiz

Re: How to access parameters from another method in the same script

  #2  
Nov 2nd, 2007
Hey There,

The simplest way would be to have the first method/function return the result:

return 10001 - or return $variable

Then call method/function 2 with the return variable from method/function 1 as its argument.

do_b 10001 - or do_b $variable

Depending on how your shell scopes it could be as simple as that or you may have to "eval" the inital function/method as an argument to your second.

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:53 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC