The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-07-2004
rraajjiibb rraajjiibb is offline
Registered User
  
 

Join Date: Jan 2004
Posts: 24
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
}
  #2 (permalink)  
Old 06-08-2004
rraajjiibb rraajjiibb is offline
Registered User
  
 

Join Date: Jan 2004
Posts: 24
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.....
  #3 (permalink)  
Old 06-09-2004
scmay scmay is offline
Registered User
  
 

Join Date: Apr 2004
Location: Melbourne
Posts: 15
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
  #4 (permalink)  
Old 06-09-2004
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
This bit is all wrong....
Code:
if (reference==no) then
/Ref: yes/ {
reference_pnoffset=$6;
else 
reference_pnoffset="SAME";
endif
- if statements do not use "then" or "endif"
- you cannot use an if statement outside of an action
  #5 (permalink)  
Old 06-09-2004
rraajjiibb rraajjiibb is offline
Registered User
  
 

Join Date: Jan 2004
Posts: 24
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
}


.....
  #6 (permalink)  
Old 06-09-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Even though I am still baffled by what is going on in this post, this seems to work for me, making some assumptions about what it is you are trying to achieve....

Code:
#This awk script collects the undec neighbour info
#
BEGIN { 
   printf "SOURCE\tSECTOR\tPNPHASE\tLEVEL\tREFERENCE\tEVENTNO\n"
   RS="\n===*\n"
}
{
   srce=$14;
   sector=$16;
   reference=$20;
   eventno=$22;
   pnphase=$28;
   level=$18/-2;
}
{ if (reference=="yes") {
      reference_pnoffset="SAME";
      print srce"\t"sector"\t"pnphase"\t"level"\t"reference_pnoffset"\t"eventno
  }
}
{ if (reference=="no") {
   if ($0 ~ /Ref: yes/ ) {
      reference_pnoffset=$39;
      print srce"\t"sector"\t"pnphase"\t"level"\t"reference_pnoffset"\t"eventno
    }
  }
}
Any good to you? You'll probably have to adjust some of the field numbers (e.g. $39) as it's hard to tell from your data file what information you're pulling out of it.

Cheers
ZB

Last edited by zazzybob; 06-09-2004 at 09:54 AM..
  #7 (permalink)  
Old 06-10-2004
rraajjiibb rraajjiibb is offline
Registered User
  
 

Join Date: Jan 2004
Posts: 24
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:25 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0