Script - Expression not complete more tokens expected

I have the following script to output a report of response times - but it is throwing the error:

./jobname[46]: -: 0403-053 Expression is not complete; more tokens expected.

Here is the code, any ideas what the problem is?

(line 46 is simply, LC=0)

FILE2=/templogs/access_log
FILE3=/templogs/access_log.1
integer LINES=0
integer i5=0
integer i10=0
integer i20=0
integer i30=0
integer i60=0
integer i60p=0
integer TIME=0
integer U=0
integer T=0
integer C=0
typeset -i LT=0
typeset -i LC=0
 
echo "Time              Total       0-5            5-10           10-20          20-30          30-60          60+    Users   Avg tm"
echo ------------------------------------------------------------------------------------------------------------------------------

for HOURS in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
do
    for MINS in 0[0-9] 1[0-9] 2[0-9] 3[0-9] 4[0-9] 5[0-9]
    do
        MYTIME=`echo $MINS | cut -d"[" -f1`
        #get users
        T=0
        C=0
 
        for U in `grep "^$HOURS" /templogs/joblog.users | grep -v "Start" | cut -d" " -f2`
        do
                C=$C+1
                T=$T+$U
        done
 
        T=$T*2
 
        grep "20..:$HOURS:${MINS}" $FILE2 > $FILE3
        i5=0
        i10=0
        i20=0
        i30=0
        i60=0
        i60p=0
        LINES=`wc -l $FILE3 | awk '{printf("%d\n",$1);}`
        LT=0
        LC=0
 
        for TIME in `cat $FILE3 | awk '{printf("%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n",$16,$15,$14,$13,$12,$11,$10,$9,$8,$7,$6,$5,$4,$3,$2,$1);}' | awk '{printf("%s\n",$1);}'`
        do
 
                LT=$LT+$TIME
                LC=$LC+1
                if [ $TIME -lt 5 ]; then
                        i5=$i5+1
                elif [ $TIME -lt 10 ]; then
                        i10=$i10+1
                elif [ $TIME -lt 20 ]; then
                        i20=$i20+1
                elif [ $TIME -lt 30 ]; then
                        i30=$i30+1
                elif [ $TIME -lt 60 ]; then 
                        i60=$i60+1
                else 
                        i60p=$i60p+1
                fi
 
        done
 
        if [ $C -eq 0 ]; then
                C=1
        fi
 
        if [[ -s $FILE3 ]]; then
        echo ${HOURS}:${MYTIME} $LINES $i5 $i10 $i20 $i30 $i60 $i60p $T $C $LT $LC| awk '{ printf("%s0:00-%s9:59 %5d %5d (%05.2f%%) %6d (%05.2f%%) %4d (%05.2f%%) %4d (%05.2f%%) %4d (%05.2f%%) %4d (%05.2f%%)  %5.1f  %5.1f\n",$1,$1,$2,$3,($3*100/$2),$4,($4*100/$2),$5,($5*100/$2),$6,($6*100/$2),$7,($7*100/$2),$8,($8*100/$2),($9/$10),($11/$12));}'
        fi
    done
done

I would suspect the missing '

You haven't closed the single quotes around your awk script:

LINES=`wc -l $FILE3 | awk '{printf("%d\n",$1);}'`

Better is:

LINES=`wc -l < "$FILE3"`

I'm ignoring the many other bad practices in your script; I need to get some sleep!

Interesting, as I have amended to......

LINES=`wc -l $FILE3 | awk '{printf("%d\n",$1);}'`

......and still get the same error.

I have also tried......

LINES=`wc -l < "$FILE3"`

......and again, the same.

Any ideas ?!!??

The variable name LINES is reserved. It's to do with the number of lines on a terminal screen.

Try changing the name of the variable.

And the variable TIME - also reserved.

The more I look the more I see.
There is a variable $T , I suspect incorrect substitution in $TIME .

The line "for TIME in" has potential to be too long for the shell depending on how many lines there are in $FILE3 .

TIME is not reserved, but it's not a good idea to use uppercase variable names as there is too great a risk of conflicting with variables set by the shell.

There are only two shell variables (in bash) which are not uppercase, auto_resume and histchars.

Thanks cfajohnson. I was wrong about $TIME (thinking of another O/S). Thankfully the script doesn't contain $SECONDS !

The $T substitution in $TIME rather than ${TIME} is still an issue.

$TIME is the same as ${TIME} and will never be interpreted as ${T}IME

There are too many other things wrong with the script that could affect it adversely.

Sorry cfajohnson. You are correct again. Some issues that I have seen and avoid in the past definitely do not apply to the script under examination.
I am left with the command line expanding to a line which is too long to process in the shell. It would help to see the input data.

We also don't know which shell version we are dealing with. On IBM machines it is quite easy to be running ksh88 when we might expect at least ksh93.

Thanks for your reply folks!

This script is on a UNIX server, using ksh93.

It's a script which has been around for ages, not written by me (not that I'm trying to avoid blame!) and has previously worked fine.

This is the contents of FILE3:

128.11.82.3 - - [12/Feb/2010:00:00:00 +0000] "HEAD / HTTP/1.1" 200 -
163.238.11.120 - - [12/Feb/2010:00:00:01 +0000] "GET /Buy/Main/aw?awr=j&awsn=awpoll HTTP/1.1" 200 46
133.20.81.54 - - [12/Feb/2010:00:00:00 +0000] "POST /Buy/Main/ad/login/SSOActions?awr=1 HTTP/1.1" 302 80

It sounds like the script is a bit cowboy-ish? Either way, I'm just after getting it working rather than a complete re-write (unless of course a re-write is required to get it working).

I've amended FILES to FILEZ as a quick test - but again, the same error.

Any more thoughts?