Script - Expression not complete more tokens expected


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script - Expression not complete more tokens expected
# 1  
Old 02-12-2010
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:

Code:
./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)

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


Last edited by Scott; 02-12-2010 at 06:38 AM.. Reason: Code tags, please...
# 2  
Old 02-12-2010
Quote:
Originally Posted by daveaasmith
Code:
        LINES=`wc -l $FILE3 | awk '{printf("%d\n",$1);}`

I would suspect the missing '
# 3  
Old 02-12-2010
Quote:
Originally Posted by daveaasmith
I have the following script to output a report of response times - but it is throwing the error:

Code:
./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)

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


You haven't closed the single quotes around your awk script:
Code:
LINES=`wc -l $FILE3 | awk '{printf("%d\n",$1);}'`

Better is:
Code:
LINES=`wc -l < "$FILE3"`

I'm ignoring the many other bad practices in your script; I need to get some sleep!
# 4  
Old 02-12-2010
Interesting, as I have amended to......

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

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

I have also tried......

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

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

Any ideas ?!!??

Last edited by daveaasmith; 02-12-2010 at 07:32 AM.. Reason: Code tags
# 5  
Old 02-12-2010
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 .

Last edited by methyl; 02-12-2010 at 01:43 PM.. Reason: TIME
# 6  
Old 02-12-2010
Quote:
Originally Posted by methyl
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.

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.
# 7  
Old 02-12-2010
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting error in bash script; expr $a + 1: integer expression expected

Hi, I am new to shell/bash script. I am trying to run below script #!/bin/bash a=0 b=10 if then echo "a is equal to be" else echo "a is not equal to be" fi MAX=10 while do echo $a a='expr $a + 1' done (1 Reply)
Discussion started by: Mallikgm
1 Replies

2. Shell Programming and Scripting

Getting error -: more tokens expected in shell script

Hi can someone help me to resolve the error for this condition if ] && ]; then i am passing the values $k and $kkm i am getting the error like "-: more tokens expected" Thanks in Advance (5 Replies)
Discussion started by: makigate
5 Replies

3. Shell Programming and Scripting

AIX 6.1 Error: 0403-053 Expression is not complete; more tokens expected.

Hi I have been trying every possible solution available for this error on this Forum but could not resolve it. When i am running the below script i get this error.:mad: sh diskMonitor.sh diskMonitor.sh: -: 0403-053 Expression is not complete; more tokens expected. diskMonitor.sh: -:... (5 Replies)
Discussion started by: nitinkatipn
5 Replies

4. UNIX for Dummies Questions & Answers

Integer expression expected error in script

When i run the following code i get an error that says Integer expression expected! How do i fix this? #!/bin/bash if ;then echo "wrong" exit 1 fi if ;then for i in /dev;do if ;then echo $i ls -l fi (4 Replies)
Discussion started by: kotsos13
4 Replies

5. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

6. Shell Programming and Scripting

if script error: integer expression expected

Hi, i am making a simple program with a optional -t as the 3rd parameter. Submit course assignment -t dir In the script, i wrote: #!/bin/bash echo "this is course: ${1}" echo "this is assignment #: ${2}" echo "late? : ${3}" if then echo "this is late" fi but this gives me a :... (3 Replies)
Discussion started by: leonmerc
3 Replies

7. Shell Programming and Scripting

:integer expression expected

Hi, echo $i until || do read NUM if && ; then printf "$FBOLD\nInvalid number, please enter valid backup number: $FREG" fi done Getting below error : ./import_location.sh: line 234: [: : integer expression expected ./import_location.sh: line 234: [: :... (5 Replies)
Discussion started by: milink
5 Replies

8. Shell Programming and Scripting

+: more tokens expected

Hey everyone, i needed some help with this one. We move into a new file system (which should be the same as the previous one, other than the name directory has changed) and the script worked fine in the old file system and not the new. I'm trying to add the results from one with another but i'm... (4 Replies)
Discussion started by: senormarquez
4 Replies

9. Fedora

"integer expression expected" error with drive space monitoring script

Hi guys, I am still kinda new to Linux. Script template I found on the net and adapted for our environment: #!/bin/sh #set -x ADMIN="admin@mydomain.com" ALERT=10 df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output; do #echo $output ... (2 Replies)
Discussion started by: wbdevilliers
2 Replies

10. Shell Programming and Scripting

: + : more tokens expected

Hello- Trying to add two numbers in a ksh shell scripts and i get this error every time I execute stat1_ex.ksh: + : more tokens expected stat1=`cat .stat1a.tmp | cut -f2 -d" "` stat2=`cat .stat2a.tmp | cut -f2 -d" "` j=$(($stat1 + $stat2)) # < Here a the like the errors out echo $j... (3 Replies)
Discussion started by: Nomaad
3 Replies
Login or Register to Ask a Question