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:
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