If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > awk syntax issue

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-18-04, 06:01
rraajjiibb rraajjiibb is offline
Registered User
 
Join Date: May 2004
Posts: 5
awk syntax issue

I am unable to trace the syntax error reported.... can any one help?

#codefor assert9419
#rchakra18jun2004
function hextodec(hexa) {
result=0;
lon = length(hexa);
#print "long:"lon
for (i = 1; i <= lon ; i++)
{
k = substr(hexa, lon + 1 - i, 1);
#print "k:"k
j=0
if (tolower(k) == "a") j=10;
if (tolower(k) == "b") j=11;
if (tolower(k) == "c") j=12;
if (tolower(k) == "d") j=13;
if (tolower(k) == "e") j=14;
if (tolower(k) == "f") j=15;
if (tolower(k) == 1) j=1;
if (tolower(k) == 2) j=2;
if (tolower(k) == 3) j=3;
if (tolower(k) == 4) j=4;
if (tolower(k) == 5) j=5;
if (tolower(k) == 6) j=6;
if (tolower(k) == 7) j=7;
if (tolower(k) == 8) j=8;
if (tolower(k) == 9) j=9;
#print "j2:"j
result = result + j * 16 ^ ( i -1 );
}
return result;
}
#aeert9419..modified by rajibchak
#dtd:18 june2004
BEGIN{
printf "Cell\tCRC\tCCU\t Unslotted \tSlotted \tOverhead \tCAM\tOrder \tAuthChal \tSSD \tFeatNot \tSDRM \tDBM \tGPM \tECAM \tBSMS\n"}

{
if ( ( $0 ~ /Assert/ ) && ( $0 ~ /9419/ ) ) {
#print l;
split( $0,a );
cell = a[3];
#print cell;
CRC = a[7];
CCU = a[9];
CCU=substr(CCU, 1, 1);
#printf "%s\t%s\t%s\t", cell,CRC,CCU >> salida;
printf "%s\t%s\t%s\r", cell,CRC,CCU;
getline;
getline;
getline;
getline;
getline;
getline;
#print l;
split($0,D);
#print D[3]; print D[4];print hextodec(D[4])
printf "%d\t", hextodec(D[3]);
printf "%d\t", hextodec(D[4]);
printf "%d\t", hextodec(D[5]);
printf "%d\t", hextodec(D[6]);
printf "%d\t", hextodec(D[7]);
printf "%d\t", hextodec(D[8]);
getline ;
split($0,D);
printf "%s\t", hextodec(D[1]);
printf "%s\t", hextodec(D[2]);
printf "%s\t", hextodec(D[3]);
printf "%s\t", hextodec(D[4]);
printf "%s\t", hextodec(D[5]);
printf "%s\t", hextodec(D[6]);
printf "%s\t", hextodec(D[7]);
printf "%s\n", hextodec(D[8]);
}



......

when run thru
awk -f 9419test.awk /omp-data/logs/aplogs/20040617.DBG|more


... throws
awk: syntax error near line 1
awk: bailing out near line 1


pl help....

I tried putting the function statement at the end also... but it says the same at the line containing the function statement...
Reply With Quote
  #2 (permalink)  
Old 06-18-04, 08:03
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
you have dis-ballanced '{' for action block - not sure if you have it in your original file - missing closing '}'. Check your parents:

{
if ( ( $0 ~ /Assert/ ) && ( $0 ~ /9419/ ) ) {
.....
.....
}

}
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
  #3 (permalink)  
Old 06-19-04, 01:05
rraajjiibb rraajjiibb is offline
Registered User
 
Join Date: May 2004
Posts: 5
it was just a cut paste error...

I do have it in my original file...

the error is the same..

pl help
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On