You list the working code, but not the code that's broken

makes it a little hard to help.
I'll provide a simplified, working, example... maybe the problem will pop out at you?
My input file (called z.in):
Code:
10,ten
3,three
1,one
From the command line:
Code:
cat z.in |awk '{FS=","; sum += $1} END {print sum}'
13
Putting the awk junk in a script. Contents of z.awk:
Code:
{FS=","; sum += $1} END {print sum}
and the result:
Code:
awk -f z.awk z.in
13
Putting it all in a script. Contents of z.ksh:
Code:
#!/bin/ksh
awk -f z.awk z.in
And running it: