Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-22-2010
Registered User
 
Join Date: Apr 2010
Posts: 12
Thanks: 4
Thanked 0 Times in 0 Posts
+: 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 getting this token error. Could anyone be kind to see what i'm doing wrong.

HERE ARE THE RESULTS

Code:
NUM1b = 8
NUM1a = 0
./magADD.ksh[77]: +: more tokens expected
NUM1 = 0 and NUM2= 8
ERROR- failed to run.

See detail in log file below:

Here is the shell script

Code:
TMPFILE1=${TMPDIR}/mag_tmp1_9686.out
67 echo "${TMPFILE1}"
68 TMPFILE2=${TMPDIR}/mag_tmp2_9686.out
69 echo "${TMPFILE2}"
70 TMPFILE3=${TMPDIR}/mag_cnt.txt
71 echo "${TMPFILE3}"
72 #check db access
73 NUM1b=`grep "ORA-00942" ${TMPFILE2} |wc -l`
74 echo "NUM1b = $NUM1b"
75 NUM1a=`grep "Table dropped" ${TMPFILE1} |wc -l`
76 echo "NUM1a = $NUM1a"
77 let NUM1=$NUM1b + `grep "Table dropped" ${TMPFILE1} |wc -l`
78 NUM2=`grep "Table created" ${TMPFILE1} |wc -l`
79 echo "NUM1 = $NUM1 and NUM2=$NUM2"
80 if [ "${NUM1}" != "${NUM2}" ]
81 then
82 echo "ERROR- failed to run. See detail in log file below:\n" >> $LOGFILE
83 exit
84 fi
85
86 echo "Done ${MAIN_SQL}.\n"
87 exit


Here is the content on each tmp file

Code:
$ more mag_tmp1_9686.out
ORA-00942
ORA-00942
ORA-00942
ORA-00942
ORA-00942
ORA-00942
ORA-00942
Table created
Table created
Table created
Table created
Table created
Table created
Table created
Table created
 
 
$ more mag_tmp2_9686.out
ORA-00942
ORA-00942
ORA-00942
ORA-00942
ORA-00942
ORA-00942
ORA-00942
ORA-00942

I hope i provide enough info.

Last edited by Franklin52; 06-22-2010 at 10:09 AM.. Reason: Please use code tags
Sponsored Links
    #2  
Old 06-22-2010
Moderator
 
Join Date: Feb 2007
Location: The Netherlands
Posts: 7,500
Thanks: 73
Thanked 473 Times in 452 Posts
Remove the spaces around the "+" sign:

Code:
let NUM1=$NUM1b+`grep "Table dropped" ${TMPFILE1} |wc -l`

or use the POSIX way to add the values:

Code:
NUM1=$((NUM1b + `grep "Table dropped" ${TMPFILE1} |wc -l`))

The Following User Says Thank You to Franklin52 For This Useful Post:
senormarquez (06-22-2010)
Sponsored Links
    #3  
Old 06-22-2010
Registered User
 
Join Date: Apr 2010
Posts: 12
Thanks: 4
Thanked 0 Times in 0 Posts
Thanks. removing the spaces didn't work but adding in the $(( )) did help.
My 'IF' statement fail though even though both numbers are 8

NUM1b = 8
NUM1a = 0
NUM1 = 8 and NUM2= 8
ERROR- failed to run mag_rpt.sql. See detail in log file below:


could it be bc of the spaces in NUM2
how would i remove that?
    #4  
Old 06-22-2010
Registered User
 
Join Date: Jun 2010
Posts: 55
Thanks: 3
Thanked 11 Times in 11 Posts
If you are trying to compare numbers, use the numeric comparison operator:

Code:
80 if [ "${NUM1}" -ne "${NUM2}" ]

Or:

Code:
80 if (( NUM1 != NUM2 ))


Last edited by a_programmer; 06-22-2010 at 10:21 AM.. Reason: Gave wrong operator in the second code snippet
The Following User Says Thank You to a_programmer For This Useful Post:
senormarquez (06-22-2010)
Sponsored Links
    #5  
Old 06-22-2010
Registered User
 
Join Date: Apr 2010
Posts: 12
Thanks: 4
Thanked 0 Times in 0 Posts
Fantastic. It worked. Thanks alot for your help.
Sponsored Links
Closed Thread

Tags
+: more tokens expected

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script - Expression not complete more tokens expected daveaasmith Shell Programming and Scripting 9 02-15-2010 05:11 AM
Replacing tokens abhinav192 Shell Programming and Scripting 3 11-25-2009 11:42 AM
: + : more tokens expected Nomaad Shell Programming and Scripting 3 04-17-2008 02:49 PM
reverse tokens with sed markc Shell Programming and Scripting 1 02-22-2008 12:55 AM
tokens in unix ? seaten UNIX for Dummies Questions & Answers 6 05-09-2005 04:57 AM



All times are GMT -4. The time now is 02:03 AM.