![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| when executing .sh script in telnet error "script not found" | smiley | Shell Programming and Scripting | 1 | 04-22-2008 01:01 PM |
| Error in the script | krworks | Shell Programming and Scripting | 5 | 04-18-2008 01:31 AM |
| awk Shell Script error : "Syntax Error : `Split' unexpected | Herry | UNIX for Dummies Questions & Answers | 2 | 03-17-2008 11:16 AM |
| Script error | Katkota | UNIX for Dummies Questions & Answers | 3 | 01-22-2008 06:02 PM |
| script error | MANISH KU | Shell Programming and Scripting | 5 | 09-01-2007 06:13 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
error in awk script
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_pnoffset } |
|
||||
|
I think my previous post did not receive any reply as it needs more clarification...
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..... |
|
||||
|
Hi, just looked at your code and thought about the logic.
if (reference==no) then you might want to do it like this if (reference=="no") then since you are comparing to a string. Also, if I am not mistaken it only assigns value to reference if it finds Primary, else reference==null.....you might wanna review that. Not sure if it works, but just giving my point of view ![]() |
|
||||
|
i have tweaked it but still have some problem as ...
my o/p looks as follows... notice that the same event no is repaeted.. i do't want that.. pl help SOURCE SECTOR PNPHASE LEVEL REFERENCE EVENTNO 66 3 0x79a8 -9 SAME 22424 66 3 0x79a8 -9 SAME 22424 66 3 0x79a8 -9 SAME 22424 66 3 0x79a8 -9 255 22424 66 3 0x79a8 -9 SAME 22424 66 3 0x79a8 -9 SAME 22424 66 2 0x79a8 -9 SAME 22429 66 2 0x79a8 -9 SAME 22429 66 2 0x79a8 -9 SAME 22429 66 2 0x79a8 -9 423 22429 66 2 0x79a8 -9 SAME 22429 66 2 0x79a8 -9 SAME 22429 66 2 0x79a8 -7.5 SAME 22430 66 2 0x79a8 -7.5 SAME 22430 66 2 0x79a8 -7.5 423 22430 66 2 0x79a8 -7.5 SAME 22430 66 2 0x79a8 -7.5 SAME 22430 66 2 0x79a8 -7.5 SAME 22430 ............. my code now looks as... #This awk script collects the undec neighbour info # BEGIN { printf "SOURCE\tSECTOR\tPNPHASE\tLEVEL\tREFERENCE\tEVENTNO\n" } /Primary/ { srce=$4; sector=$6; reference=$10; eventno=$12; getline; pnphase=$6; level=$8/-2; } (reference=="yes") { reference_pnoffset="SAME"; print srce"\t"sector"\t"pnphase"\t"level"\t"reference_pnoffset"\t"eventno } (reference==no) { if ($0 ~ /Ref: yes/ ) reference_pnoffset=$6; print srce"\t"sector"\t"pnphase"\t"level"\t"reference_pnoffset"\t"eventno } ..... |
|
||||
|
thanks guys.. for ur look into...
I still have the problem... zazzybob.... let me chart the flow of the code 1> Every record will be between two "=============" . This is pretty clear from the sample i posted. 2> If we have "Ref: yes" in the line which contains the pattern "Primary" , then we pick up the field "PN-phase: ??????? " from the line next to it( that contains "Primary") and also 3> In case we have "Ref: no" in the line which contains the pattern "Primary" , then we pick up the field "Pn_offset: " from the immediate next line that has "Ref: yes" . e.g ======================================================================= Record: 42759421 Version: 2 Timestamp: Wed Jun 9 15:00:09 2004 Primary (Reporting) Cell: 25 Sector: 2 Carrier: 2 Ref: no Event: 20984 Missing Pilot: Keep: 1 PN-Phase: 0x50fc Strength: 29 Secondary Sector Information: Slot 1: Keep: 1 Pn_offset: 84 Strength: 27 Ref: no Slot 2: Keep: 1 Pn_offset: 480 Strength: 29 Ref: yes ======================================================================= in this case the o/p will look like SOURCE SECTOR PNPHASE LEVEL REFERENCE EVENTNO 25 2 0x50fc -14.5 480 20984 Whereas as in this case ======================================================================= Record: 42759422 Version: 2 Timestamp: Wed Jun 9 15:00:10 2004 Primary (Reporting) Cell: 14 Sector: 2 Carrier: 2 Ref: yes Event: 12583 Missing Pilot: Keep: 1 PN-Phase: 0x5b88 Strength: 26 Secondary Sector Information: Slot 1: Keep: 1 Pn_offset: 381 Strength: 24 Ref: no Slot 2: Keep: 1 Pn_offset: 54 Strength: 29 Ref: no ======================================================================= the o/p will be SOURCE SECTOR PNPHASE LEVEL REFERENCE EVENTNO 14 2 0x5b88 -13 SAME 12583 .... PLS HELP |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|