Hi there, I have created an array in which I store multiple names. I thne run a for loop to iterate through 2 names in the array. I then run another script and input the current name as an argument to that script. my problem is that during the first iteration, the script works fine, but during the second iteration, the second name does not get passed to the script, but the first one gets passed again.
say I have two inputs: apples, oranges stored in jBPMarray.
in for loop:
in first iteration: i want to run
Code:
/usr/local/report.sh apples
in second report I want to run:
Code:
/usr/local/report.sh oranges
instead the argument apples get used twice.
here is my code. I think there is something wrong with my syntax inside the for loop
Code:
#!/usr/bin/bash
jBPMarray=("$@")
echo -n "Specify number of reports to generate per hour : "
read num_reports_per_hr
echo -n "Specify a timestamp e.g. ( 01/01/2011 ) : "
read time_stamp;
output_dir=""
rpt_file_name=""
process_itr=${#jBPMarray[@]}
echo "process_itr: "
echo $process_itr
index_itr=0
while [ "$process_itr" -ne 0 ]
do
echo "current iteration: ${process_itr}"
for ((j=0;j<=($num_reports_per_hr - 1);j++))
do
echo "current number: "
echo $j
"/usr/local/report.sh" "$jBPMarray["$j"+"$index_itr"]"
echo "Current Process:"
echo ${jBPMarray[$j]}
process_itr=$(($process_itr - 1));
echo "process_itr: "
echo $process_itr
if [ "$process_itr" -eq 0 ]
then
break;
fi
done
echo "Sleeping"
sleep 10
index_itr="$index_itr"+"$num_reports_per_hr"
done
Any advise would be well appreciated. Plz Help! Thanks!!!