Inputs from a file

Hi,
I have a shell script that has to taken inputs from a file say "Inputs". Now I take 2 inputs at a time. Suppose the Inputs file contains numbers like
2
3
4
5
Now I have a written a script for adding 2 numbers. When I run the script for first time 2 and 3 must be the inputs. When i run the script for the second time the inputs should be 4 and 5. Is there is any way to do this. I know that the inputs can be taken using 'exec'. But , how can i do for this case.

Thanx in advance

cat filename | paste - - | while read a b
do
vl=$(( a + b ))
echo $vl
done

if you are very particular to include your script to add the numbers, remove the line vl=$(( a + b )) and add your script name with variable a and b.

Thanks a lot

this is a round-abt way, better dont use it i thought of giving it a try thats it

# !/usr/bin/ksh
#1

#The above line indicates the run

num=`sed 2q $0 | tail -1 | sed 's/#//'`
cnt=1
counter=0
sum=0

while read line
do
if [ $cnt -eq $num ]
then
  if [ $counter -le 1 ]
  then
     sum=$(($sum + $line))
     counter=$(($counter + 1))
  else
     break
  fi
else
  cnt=$(($cnt + 1))
fi
done < data

echo "sum is $sum"
cnt=$(($cnt + 2))

sed 1q $0 > tmp
echo "#$cnt" >> tmp
awk 'NR>2' $0 >> tmp

mv tmp $0
chmod 744 $0
exit 0
>cat data
2
3
4
5
6
7
8
9
>sum.ksh
sum is 5

>sum.ksh 
sum is 9

>sum.ksh 
sum is 13

the above three are consecutive runs

Doing away with the cat and the paste, this will work

#! /bin/ksh

echo "2
 3
 4
 5" | while read line
do
        NUM1=$line
        read line
        NUM2=$line
        SUM=$((NUM1+NUM2))
        echo $SUM
done

If reading inputs from a file, then this would do

#! /bin/ksh

while read line
do
        NUM1=$line
        read line
        NUM2=$line
        SUM=$((NUM1+NUM2))
        echo $SUM
done < input.file