Sponsored Content
Top Forums Shell Programming and Scripting Pass parameters to a function and running functions in parallel Post 302875205 by Ravindra Swan on Tuesday 19th of November 2013 01:08:18 AM
Old 11-19-2013
Pass parameters to a function and running functions in parallel

Hi ,

I have a script which is using a text file as I/P.
I want a code where it reads n lines from this file and pass the parameters to a function and now this script should run in such a way where a function can be called in parallel with different parameters. Please find below my script, it is actually loading tables:
Code:
full()
{
echo "You entered full $1,$2,$3"
db2 "call util.DATA_REFRESH('LOAD','$1','$2','$3','$2','R','?',?)"  
rc=$?
if [ "$rc" -ne 0 ] ;then
echo "$1.$2" >>failure_list.txt
else 
echo "$1.$2" >>Success_list.txt
fi
}
schema=schema
table=table
nickname=nickname
 
split -l 4 full_refresh.txt
rc=$?
if [ "$rc" -ne 0 ] ;then
mutt -s "Unable to split" $mail_list
exit; 
fi
ls xa*  > list.txt
rc=$?
if [ "$rc" -ne 0 ] ;then
mutt -s "Unable to gather splitted file names" $mail_list 
exit;
fi
 
while read list
do
read_line=0
 
while read line1
do
read_line=`expr $read_line + 1`
echo $line1
eval "$schema""$read_line"=`echo $line1|awk 'BEGIN { FS = "|" } ; {print $1}'`
eval "$table""$read_line"=`echo $line1|awk 'BEGIN { FS = "|" } ; {print $2}'`
eval "$nickname""$read_line"=`echo $line1|awk 'BEGIN { FS = "|" } ; {print $3}'`
export "$schema""$read_line"
export "$table""$read_line"
export "$nickname""$read_line"
 
done < list
 
full $schema1 $table1 $nickname1 & full $schema2 $table2 $nickname2 & full $schema3 $table3 $nickname3 & full $schema4 $table4 $nickname4


Please check where am i going wrong.
full_refresh.txt: input file
here i tried using split command to read 4 lines at once.


Thanks a lot in advance

Last edited by Ravindra Swan; 11-19-2013 at 03:12 AM.. Reason: Small change in script
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

passing command line parameters to functions - sh

All, I have a sh script of the following tune: function a () { #functionality.. } function b () { #functionnlity.. } function check () { # this function checks for env and if all fine call build } function usage () { #sh usage details } function build () { #calls either a or b or... (5 Replies)
Discussion started by: vino
5 Replies

2. Shell Programming and Scripting

Run a same script in parallel with diffs parameters

i have script say some_script.ksh that takes an argument I need to run some_script.ksh in background parallely at the sametime with different arguments. Once all the background jobs complete, i need to run this script again in parallel with another 5 set of arguments. Would really... (1 Reply)
Discussion started by: hyennah
1 Replies

3. Shell Programming and Scripting

Get the List of functions with modified parameters

Hi I have 2 files a.c and a.bak where I changed long to int using awk script. I want to get the list of functions whose parameters got modified for eg: fun ( long a, long b ) might be changed to fun ( int a, int b ) (1 Reply)
Discussion started by: Sivaswami
1 Replies

4. Shell Programming and Scripting

Handling parameters in Shell Functions

Hi, Please help me with the below situation where I have to handle the parameters passed to a function in a unique way. Below is the code, which I am trying to execute. I basically want to pass the parameter to a function, where I am trying to get user input into array(s). I want to name... (7 Replies)
Discussion started by: bharath.gct
7 Replies

5. Shell Programming and Scripting

Pass parameters to function

Hi, for example I have this function: function get_param () { test=echo "some string" test2=echo "someother string" } I want to call this function and get test or test2 result, how do I do that ? Thank you (2 Replies)
Discussion started by: ktm
2 Replies

6. Shell Programming and Scripting

Calling multiple functions in parallel

Hello, I have multiple functions within a shell script. eg. function_database_backup, unix_tar_creation, etc. I would like to run these functions in parallel, as each is independent of the other. If these were simple commands, I could have probably run each of the commands in background. ... (1 Reply)
Discussion started by: neil.k
1 Replies

7. Shell Programming and Scripting

How to execute functions or initiate functions as command line parameters for below requirement?

I have 7 functions those need to be executed as command line inputs, I tried with below code it’s not executing function. If I run the ./script 2 then fun2 should execute , how to initiate that function I tried case and if else also, how to initiate function from command line if then... (8 Replies)
Discussion started by: saku
8 Replies

8. Shell Programming and Scripting

Parallel processing for functions in xargs

I have a script (ksh) which tries to run a function in parallel for performance gains. I am also trying to limit the number of parallel child processes to avoid overloading the system by using a variable to count triggered processes and waiting for completion e.g. do_something () { ... } ... (9 Replies)
Discussion started by: jawsnnn
9 Replies

9. Shell Programming and Scripting

Python passing multiple parameters to functions

Hi, I am a beginner in python programming. In my python script have a main function which calls several other functions. The main function gets its input by reading lines from a input text file. I call the main function for every line in input text file through a loop. def main(line): var1... (6 Replies)
Discussion started by: ctrld
6 Replies

10. Shell Programming and Scripting

How to pass subject,mailbody and filename as parameters to function?

Hi Experts, how to pass subject,mailbody and filename as parameters to function. mode=$1 file=/db/files/uniq.txt mail_send() { export MAILPART=$(uuidgen) export MAILPART_BODY=$(uuidgen) { echo "TO:nalu.d@hes.com" echo "Subject:$subject" echo "MIME-Version: 1.0" ... (0 Replies)
Discussion started by: nalu
0 Replies
MSSQL_NUM_FIELDS(3)													       MSSQL_NUM_FIELDS(3)

mssql_num_fields - Gets the number of fields in result

SYNOPSIS
int mssql_num_fields (resource $result) DESCRIPTION
mssql_num_fields(3) returns the number of fields in a result set. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). RETURN VALUES
Returns the number of fields, as an integer. EXAMPLES
Example #1 mssql_num_fields(3) example <?php // Connect to MSSQL and select the database $link = mssql_connect('KALLESPCSQLEXPRESS', 'sa', 'phpfi'); mssql_select_db('php', $link); // Select some data from our database $data = mssql_query('SELECT [name], [age] FROM [php].[dbo].[persons]'); // Construct a table echo '<table border="1">'; $header = false; // Iterate through returned results while ($row = mssql_fetch_array($data)) { // Build the table header if (!$header) { echo '<thead>'; echo '<tr>'; for ($i = 1; ($i + 1) <= mssql_num_fields($data); ++$i) { echo '<td>' . ucfirst($row[$i]) . '</td>'; } echo '</tr>'; echo '</thead>'; echo '<tbody>'; $header = true; } // Build the row echo '<tr>'; foreach($row as $value) { echo '<td>' . $value . '</td>'; } echo '</tr>'; } // Close table echo '</tbody>'; echo '</table>'; // Clean up mssql_free_result($data); mssql_close($link); ?> SEE ALSO
mssql_query(3), mssql_fetch_field(3), mssql_num_rows(3). PHP Documentation Group MSSQL_NUM_FIELDS(3)
All times are GMT -4. The time now is 11:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy