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 problem?

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

could any one tell me the error in the script here...

it says

awk: syntax error near line 15
awk: bailing out near line 15


... the awk script is attached

#This awk script collects the undec neighbour info
#
BEGIN {
printf "SOURCE\tSECTOR\tPNPHASE\tLEVEL\t\REFERENCE\n"
}
/Primary/ {
srce=$4;
sector=$6;
reference=$10;
getline;
pnphase=$6;
level=$8/-2;

}

if (reference==no) then
/Ref: yes/ {
reference_pnoffset=$6;
else
reference_pnoffset="SAME";
endif

print srce"\t"sector"\t"pnphase"\t"level"\t"reference_pn offset
}

===============
My input file looks as attcahed

================================================== =====================
Record: 24950188 Version: 2 Timestamp: Mon Jun 7 15:00:06 2004
Primary (Reporting) Cell: 30 Sector: 3 Carrier: 1 Ref: yes Event: 46988
Missing Pilot: Keep: 1 PN-Phase: 0x0191 Strength: 25
Secondary Sector Information:
Slot 1: Keep: 1 Pn_offset: 72 Strength: 26 Ref: no
================================================== =====================
Record: 24950189 Version: 2 Timestamp: Mon Jun 7 15:00:06 2004
Primary (Reporting) Cell: 30 Sector: 3 Carrier: 2 Ref: no Event: 46989
Missing Pilot: Keep: 1 PN-Phase: 0x7456 Strength: 26
Secondary Sector Information:
Slot 1: Keep: 1 Pn_offset: 357 Strength: 28 Ref: yes
Slot 2: Keep: 1 Pn_offset: 393 Strength: 29 Ref: no
================================================== =====================
Record: 24950190 Version: 2 Timestamp: Mon Jun 7 15:00:06 2004
Primary (Reporting) Cell: 30 Sector: 3 Carrier: 2 Ref: no Event: 46990
Missing Pilot: Keep: 1 PN-Phase: 0x7456 Strength: 25
Secondary Sector Information:
Slot 1: Keep: 1 Pn_offset: 357 Strength: 27 Ref: yes
Slot 2: Keep: 1 Pn_offset: 393 Strength: 30 Ref: no
================================================== =====================
Record: 24950191 Version: 2 Timestamp: Mon Jun 7 15:00:06 2004
Primary (Reporting) Cell: 30 Sector: 3 Carrier: 2 Ref: no Event: 46991
Missing Pilot: Keep: 1 PN-Phase: 0x7456 Strength: 22
Secondary Sector Information:
Slot 1: Keep: 1 Pn_offset: 357 Strength: 27 Ref: yes
Slot 2: Keep: 1 Pn_offset: 393 Strength: 32 Ref: no
================================================== =====================
...........................
what my code is attempting to do is.....

If in the second line of every record the Ref:no is set then i need to pick up the Pn_offset: value for the next line where Ref: yes is set.

Ref:no Ref:yes Pn_offset:



Now it 's alittle bit more clear i hope.....
Reply With Quote
  #2 (permalink)  
Old 06-08-04, 08:22
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
# I [bold]think[/bold] that's what you meant
#
(reference==no) {
if ($0 ~ /Ref: yes/ )
reference_pnoffset=$6;
else
reference_pnoffset="SAME";

print srce"\t"sector"\t"pnphase"\t"level"\t"reference_pn offset
}
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