Help Required


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help Required
# 1  
Old 11-23-2008
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  
Old 11-23-2008
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  
Old 11-24-2008
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!!!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help required

Hi Everyone, I need a little help in manipulating a file. This is what I need. I need to move each line barring the top 3 lines, to the right by a 8 (or some specified number ) of places. Example BEGIN: Vertices Edges Archs 1443 4042 862 4821 254 1177I want to move the... (3 Replies)
Discussion started by: scigeek
3 Replies

2. Shell Programming and Scripting

Help required

Dear All, I need to script to change TTL of all zone file in my DNS and aslo i require the serial to be updated to reduce my work load. Regards Vicky (0 Replies)
Discussion started by: search4u2003
0 Replies

3. Shell Programming and Scripting

Getting required fields from a test file in required fromat in unix

My data is something like shown below. date1 date2 aaa bbbb ccccc date3 date4 dddd eeeeeee ffffffffff ggggg hh I want the output like this date1date2 aaa eeeeee I serached in the forum but didn't find the exact matching solution. Please help. (7 Replies)
Discussion started by: rdhanek
7 Replies

4. Shell Programming and Scripting

HELP Required Please!!!!!!!!!

Dear Friends, I have a script below mentioned, it is running OK on Linux platform but somehow now i have to use SOLARIS 10 for this script, When i run this script i have some error messages also given below. Can any of you help me with this, i will be very thankful to him. ... (6 Replies)
Discussion started by: Danish Shakil
6 Replies

5. Linux

Help Required

Hi, please suggest me the possible reasons for application to get hang ???? Thanks and Regards Anand P (1 Reply)
Discussion started by: Anand Prakash
1 Replies

6. UNIX and Linux Applications

Help Required

Hi, please suggest me the possible reasons for application to get hang ???? Thanks and Regards Anand P (0 Replies)
Discussion started by: Anand Prakash
0 Replies

7. Solaris

Help required.

Hi, Iam relatively new to Shell scripting. ............ ......... Cur_log_file=`ls -lrt LOGFILE* | grep 'Jun 30' | tail -1` ............... .................. Iam trying to find some log file name to check their status, using above script line. If the log file is not avaible then rest of... (3 Replies)
Discussion started by: Lokesha
3 Replies

8. UNIX for Dummies Questions & Answers

help required

Hi All, Please help me in the following query need a command to get all the files in the present directory except the next day file format :: abc_<DD>.log $ls -l abc_10.log abc_10.log abc_11.log Now i need the output in abc.list which should contains $more abc.list abc_10.log... (5 Replies)
Discussion started by: thaduka
5 Replies

9. Programming

help required

hi i am new to c programming and found this on the net could someone tell me what it actually does, many thanks in advance cheers #include <fcntl.h> main() { int fd; fd = open("in1", O_RDONLY); printf("%d\n", fd); } and this too please #include <fcntl.h> main() { int... (1 Reply)
Discussion started by: ruffenator
1 Replies
Login or Register to Ask a Question