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
HELP Required Please!!!!!!!!! Danish Shakil Shell Programming and Scripting 6 07-30-2008 04:59 AM
Script required to get a required info from file. Pls. help me. ntgobinath Shell Programming and Scripting 2 05-31-2008 08:34 AM
SSL help required binums HP-UX 0 05-04-2006 02:03 AM
Help required on DBX Sumanth SUN Solaris 1 07-29-2004 09:54 AM
help required ruffenator High Level Programming 1 02-03-2003 11:14 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-23-2008
wakhan wakhan is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 58
Help Required

Below is my code which gives output like this: Every time we have to open the script file and change the value of TG in BEGIN. what i want to do is
that i give two three values at the sametime and then run the script and
it gives output one by one at the same time.

I think i have to define some array in which those values are defined and then
it gives those values to variable TG one by one.

Please help... if you can provide some help for coding

HTML Code:
KarachiOMP root> ./tgcmp702
DATE IN ST EN  TGN ISEIZE ISATMP   IANS OATMPT   OVFL OSEIZE OSATMP   OANS TOTUSG OOSMTCE   OOS DBLSZR NTWCONG
1121 24 23 24  606   7462   7459   3573      0      0      0      0      0  55694      0      0      0      0
1122  1  0  1  606   6593   6592   2879      0      0      0      0      0  55330      0      0      0      0
1122  2  1  2  606   4000   4000   1724      0      0      0      0      0  42891      0      0      0      0
1122  3  2  3  606    542    541    248      0      0      0      0      0  11908      0      0      0      0
1122  4  3  4  606      0      0      0      0      0      0      0      0    119      0      0      0      0
1122  5  4  5  606      0      0      0      0      0      0      0      0      0      0      0      0      0
1122  6  5  6  606      0      0      0      0      0      0      0      0      0      0      0      0      0
1122  7  6  7  606      0      0      0      0      0      0      0      0      0      0      0      0      0
1122  8  7  8  606      0      0      0      0      0      0      0      0      0      0      0      0      0
1122  9  8  9  606      0      0      0      0      0      0      0      0      0      0      0      0      0
1122 10  9 10  606      0      0      0      0      0      0      0      0      0      0      0      0      0
1122 11 10 11  606   1259   1257    645      0      0      0      0      0   3886      0      0      0      0
1122 12 11 12  606   6257   6243   3186      0      0      0      0      0  23033      0      0      0      0
1122 13 12 13  606   9770   9752   4980      0      0      0      0      0  38055      0      0      0      0
1122 14 13 14  606  11702  11685   5891      0      0      0      0      0  51436      0      0      0      0
1122 15 14 15  606  11609  11583   5803      0      0      0      0      0  48050      0      0      0      0
1122 16 15 16  606  11106  11075   5697      0      0      0      0      0  50772      0      0      0      0
1122 17 16 17  606   9674   9646   4808      0      0      0      0      0  41480      0      0      0      0
1122 18 17 18  606   8177   8169   4223      0      0      0      0      0  37136      0      0      0      0
1122 19 18 19  606  11609  11587   5922      0      0      0      0      0  49780      0      0      0      0
1122 20 19 20  606  11724  11722   5723      0      0      0      0      0  54494      0      0      0      0
1122 21 20 21  606  11981  11965   5722      0      0      0      0      0  53925      0      0      0      0
1122 22 21 22  606  11673  11667   5336      0      0      0      0      0  55016      0      0      0      0
1122 23 22 23  606  10351  10333   4747      0      0      0      0      0  55177      0      0      0      0
Code:
KarachiOMP root> vi tgcmp702

cat /omp-data/logs/5etr/081123.APX | nawk '

BEGIN {
TG=606;
        
printf ("DATE IN ST EN  TGN ISEIZE ISATMP   IANS OATMPT   OVFL OSEIZE OSATMP  OANS TOTUSG OOSMTCE   OOS DBLSZR
NTWCONG\n");
}

/TRFTR TGCOMP/ {
        getline; getline;
        split($2,a,"-");
        date=a[2]a[3];
        getline; getline; getline;
        interval=$2; split($3,a,":"); start=a[1]; split($4,a,":"); end=a[1];
}

/TGN    ISEIZE/ {
        getline;
        tgn=$1; iseize=$2; isattmp=$5; ians=$6;
}

/TGN    OATTMPT/ {
        getline;
        oattmpt=$2; ovfl=$4; oseize=$5; osattmp=$7;
}

/TGN    OANS/   {

        getline;

        oans=$2; totusg=$3;

}


/TGN    BWOUTU/ {

        getline;

        oosmtce=$4;

        oos=$5;

}


/TGN    DBLSZR/ {

        getline;

        dblszr=$2;

}


/TGN    SBBSY/  {

        getline;

        ntwcong=$4;

}


/TGN    TRKNAV/ {

        if (tgn==TG) {

printf("%s %2d %2d %2d %4d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d %6d\n", date, interval, start, end, tgn, iseize, isattmp, ians, oattmpt, ovfl, oseize, osattmp, oans, totusg, oosmtce, oos, dblszr, ntwcong);

        }

}

END {

}

Last edited by wakhan; 11-23-2008 at 05:07 AM..
  #2 (permalink)  
Old 11-23-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,643
Code:
#!/bin/ksh
for i in $@
do
nawk -v TG="$i" ' BEGIN { printf(.............).rest of nawk code'
done
each iteration of the loop wiil assign a new value to TG. No TG=something required in the BEGIN function.

usage: tgcmp702 606 607 608 609
  #3 (permalink)  
Old 11-24-2008
wakhan wakhan is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 58
HELP REQUIRED (Thnaks.............)

Thanks jim mcnamara!!

The code really works now according to my requirement.

I have made little more change as below.

#!/bin/ksh
VAL='601 602 603 604 605 ....................'
for i in $VAL
do
nawk -v TG="$i" ' BEGIN { printf(.............).rest of nawk code'
done

USAGE# ./tgcmp701

SIMPLE!!!

Thanks ALOT!!!
Sponsored Links
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 10:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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