•
•
•
•
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 391,765 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 3,209 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:
Views: 548 | Replies: 1
![]() |
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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.
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.
•
•
Join Date: Oct 2007
Posts: 256
Reputation:
Rep Power: 1
Solved Threads: 26
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
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!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Shell Scripting Marketplace
- MS Access vs. MySQL (MS Access and FileMaker Pro)
- Invoking a shell script (PHP)
- help with parrallel arrays (C++)
- Logon script errors (Windows NT / 2000 / XP / 2003)
- How to access the system environment variables in windows (Perl)
- Form not sending email (PHP)
- variable function parameters functionname(int a, ...) (C)
Other Threads in the Shell Scripting Forum
- Previous Thread: Error in script
- Next Thread: time command


Linear Mode