Script Error token '08'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script Error token '08'
# 1  
Old 08-01-2006
Question Script Error token '08'

Hi anybody
kindly help me to overcome this error,
in my following UNIX script the value of substr is the Hour position in processing records, and I want to seperate only 00 to 09 records to a seperate file, when I run this script when it reaches to 08 hour containg record it gives me 08: value too great for base (error token is '08') msg and loop goes out.

Highly appreciate if you solve this problem
tks
# ***************************************************
cat EventLogFile.txt |while read line
do
HOUR=`echo $line | awk '{printf("%s\n",substr($line,21,2))}'
hr=$HOUR

if [[ $hr -ge 0 && $hr -le 9 ]]
then
echo $line >> Event00_09on$(date "+%d")
echo "Record processing "
else
echo "Record negletting "
echo $line
fi
done
# ************************************************
# 2  
Old 08-01-2006
I faced the same issue yesterday. Perderabo pointed me to thread
http://unix.com/showthread.php?t=25095

This issue is caused by numbers starting with 0 being treated as octal numbers. 08 and 09 are invalid octal numbers, thus the message comes up. You can change the base to 10 by using 10# in front of the number.

Here's an example

let "num=10#08"


echo $num
8

Last edited by vish_indian; 08-01-2006 at 08:08 AM.. Reason: Add an example
# 3  
Old 08-04-2006
Computer

Smilie It worked Thank you so much ...
# 4  
Old 08-15-2006
Charactor number string to numeric value

Kindly tell me how to convert Charactor string (like 7865) to numaric value & numeric value to charactor string.
# 5  
Old 08-15-2006
You can also do all the work using awk only. In that case you will not have problem with pseudo octal numbers.
Code:
awk -v File=Event00_09on$(date "+%d") '
   {
      hr = substr($0,21,2);
      if (hr >= 0 && hr <= 9) {
         print "Record processing ";
         print $0 >> File;
      } else {
         print "Record negletting ";
         print $0;
      }
   }
   ' EventLogFile.txt

Jean-Pierre.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Getting this error syntax error near unexpected token `)'

Hi Everyone, my script was running Ok, but suddenly it started giving this error. ./update_env_bi.sh: line 54: syntax error near unexpected token `)' ./update_env_bi.sh: line 54: `sed -i "s/PORT=*1/PORT=$2/" repository.xml' The line 54 has this code. sed -i "s/PORT=*1/PORT=$2/"... (2 Replies)
Discussion started by: shajay12
2 Replies

2. UNIX for Beginners Questions & Answers

Syntax error near unexpected token 'do'

Hello all, Please i have this command i used to zip different files in differents directory, but i have an error. Note that when i run the command in one directory it works fine. /X5/WORK/BGH/INV/REG/pdf/SEND/BGH12523/1/*.fo /X5/WORK/BGH/INV/REG/pdf/SEND/BGH24523/1/*.fo... (3 Replies)
Discussion started by: gillesi
3 Replies

3. Shell Programming and Scripting

Syntax error near unexpected token

Hi all, I have a simple script that doesn't work somehow. I can't seem to be spotting the cause of the malfunction. count=$((1)) for item in `cat test1.txt` printf %s `sed -n $((count))p test2.txt` > test3.txt count=$((count+1)) do something done I get ; ./why.sh: line 3:... (14 Replies)
Discussion started by: y33t
14 Replies

4. Shell Programming and Scripting

Syntax error near unexpected token '('

I tried to execute the code but I got this error ./Array.c: line 9: syntax error near unexpected token '(' ./Array.c: line 9: ' nvals = get_data(a,MAXARRAY);' and #include<stdio.h> #define MAXARRAY 1000 main() { int a, nvals; nvals =... (7 Replies)
Discussion started by: sgradywhite
7 Replies

5. Shell Programming and Scripting

Cannot execute/finish script because of last line syntax error: unexpected end of file/token `done'

first of all I thought the argument DONE is necessary for all scripts that have or begin with do statements which I have on my script, However, I still don't completely understand why I am receiving an error I tried adding another done argument statement but didn't do any good. I appreciate... (3 Replies)
Discussion started by: wolf@=NK
3 Replies

6. Shell Programming and Scripting

Unexpected Token Error `;;'

Hello all, Im having an Issue with my script for switch statement , can someone let me know where do i need to correct it. 7 ##******************************************************************************************************* 8 ## ********** FUNCTION USAGE *********** ... (13 Replies)
Discussion started by: raghunsi
13 Replies

7. Shell Programming and Scripting

'unexpected token' error using FIND in script to delete old files

Hi, I am compete linux noob, but have managed to setup my Thecus N5500 to rsync to my N5200Pro to do automatic backups each night. The rsync script also moves any files deleted from the N5500 (and previously backed up to the N5200) to a _deleted folder on the N5200 so I can keep them for 30... (10 Replies)
Discussion started by: rpalmer68
10 Replies

8. Shell Programming and Scripting

syntax error near un expected token =~

Hello. Please help with this code. Returns an error message "syntax error near unexpected token =~. Conditional binary operator expected. if " ]] || " ]] then echo "Enter only valid numbers" fi (2 Replies)
Discussion started by: Pauline mugisha
2 Replies

9. Programming

Newbie Question.. -> error: syntax error before ';' token

Hello, the following is generating a error at the line "tmprintf(&tmBundle, _TMC("{0}"),Prompt);"... a bit lost as I am diving into this debug... Thank you in advance... int H_YesNo(TMCHAR *Prompt, int DefVal) { TMCHAR YesNo = '\0'; tmprintf(&tmBundle, _TMC("{0}"),Prompt); while... (3 Replies)
Discussion started by: reelflytime
3 Replies

10. UNIX for Advanced & Expert Users

Authentication token error?!?!

Hi all, I have upgraded my old RedHat 6.2 box to RedHat 7.3. I had couple hundreds of users on that box so i just migrated all the user account to a new box by transfering home directories, and appending to /etc/passwd /etc/shadow /etc/group. I have preserved all permittions. Everything works... (8 Replies)
Discussion started by: solvman
8 Replies
Login or Register to Ask a Question