The UNIX and Linux Forums  


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.

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-17-2008
timj123 timj123 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 80
Help with awk funcions

I have a issue with my script. It works for the most part but is not very
portable. Example below is sample of "input file" and cut and paste of "script.

The script works fine if The following System portions are outputted as follows:

SYSTEM CFO is followed by SYSTEM DAX
SYSTEM DAX is followed by SYSTEM TC
SYSTEM TC is followed by STETEM OND

On different Units some of the System portions are not outputted in the same
order or some of the System portions are not outputted at all.

My question is how can I modify awk functions to stop processing on one system
and start processing on the next system portion when the next system portion
is not listed in the portion itself, example of function(dAX):

Code:
   while (( getline > 0 ) && ( $3 != "TC" )) {

In the above line of code, $3 TC is the next system portion, that tells function to stop processing.

Here is sample of input file:


Code:
doal   cont   pegc   system1   call7   solh
RX SYSTEM CFO
DATE 322:47:34

DPORQ = 0        TTORQ = 0        DPINRQ= 0
MFINRQ= 0        CDIRR = 0        TCBSY = 0
TCINT = 0        TCANS = 0        TCRNG = 0
RPINRQ= 0        C6INRQ= 0        ISUPRQ= 11147
TUPRQ = 0        MFOURQ= 0        C6OURQ= 0
ISUPOR= 17417    BICCRQ= 0        BICCOR= 0
POVFL = 0

doal   cont   pegc   system1   call7   solh
RX SYSTEM DAX
DATE 322:47:34

proc   cpu    systm    load     sactv    orig    ovldpu   mmst
1      0        0        0        0        0        0        0
2      0        0        0        0        0        0        0
3      0        0        0        0        0        0        0
4      0        0        0        0        0        0        0
5      0        0        0        0        0        0        0
6      0        0        0        0        0        0        0
7      0        0        0        0        0        0        0
8      0        0        0        0        0        0        0
9      0        0        0        0        0        0        0
10     0        0        0        0        0        0        0
11     0        0        0        0        0        0        0

doal   cont   pegc   system1   call7   solh
RX SYSTEM TC
DATE 322:47:34

proc     pucco    load     chgro    chmert   chinc    chout    ceqpu
22       2        97       0        0        2707     6374     0
1        3        15011    0        0        2717     6651     0
2        3        12976    0        0        2139     6137     0
3        3        13898    0        0        2199     6583     0
4        3        15123    0        0        2478     7788     0
5        3        13823    0        0        2645     5789     0

Here is sample of script:

Code:
/usr/xpg4/bin/awk '

$3 == "CFO"    { cFO() } 
$3 == "DAX"    { dAX() } 
$3 == "TC"     { tC()  } 


function dAX(     _xm)
{
   while (( getline > 0 ) && ( $3 != "TC" )) {

do a a lot of awk stuff here....
.
.
.
.
.
   }
}

function tC(     _msx)
{
   while (( getline > 0 ) && ( $3 != "OND" )) {

do a a lot of awk stuff here....
.
.
.
.
.
   }
}

function cFO(     _iu)
{
   while (( getline > 0 ) && ( $3 != "DAX" )) {

do a a lot of awk stuff here....
.
.
.
.
.
   }
} FILENAME

Thanks in advance.
 

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 02:46 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