[SunHELP] script challenge

Naser Ali sunhelp at sunhelp.org
Wed Feb 21 18:12:18 CST 2001


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C09C64.1E512170
Content-Type: text/plain;
	charset="iso-8859-1"

Hello Every one ,
Thanks for guidance and right direction.
 
I figured the way of doing it. Below is my solution going completely "awk"
way
 
+++++++++++++++++++++++++++
BEGIN {
        NEW_LIST=0
}
{
        if ($0 ~ /^##* [0-9]*/) {
                NEW_LIST=1;
                TIMESTAMP=$2;
#               print $0;
        }
 
        while (NEW_LIST == 1) {
                if (getline != 1) break;
                if ($0 ~ /listner/)
                        NEW_LIST = 0;
                else if ($0 ~ /Average/) {
                        NEW_LIST = 0;
                        AVG_TIME = $8;
                        printf ("%s%d\n", TIMESTAMP, AVG_TIME);
                }
        }
}
++++++++++++++++++++++++++++++++++++++++++++++
 
#cat inputfile.txt | awk -f script.awk
 
will do the job. For further processing, call the above in a seperate shell
script and go from there.
 

-----Original Message-----
From: Michael Marziani [mailto:michael.marziani at onfiber.com]
Sent: Wednesday, February 21, 2001 6:02 PM
To: 'sunhelp at sunhelp.org'
Subject: RE: [SunHELP] script challenge


I wouldn't insult your intelligence by writing the script for you, because
this would be extremely easy to do in Perl (my scripting language of
choice).  Simply read the file in, grab the first line and snag and parse
the date, then look for the line with /Average/ in it, grab the average
ping, put them together how you want and append the output to your other
file.  The first 2 chapters of most any perl book (or web tutorial) will
give you the info to get this done in short order.
 
-Mike
 
 
 -----Original Message-----
From: Naser Ali [mailto:Ali.Naser at irs.gov]
Sent: Wednesday, February 21, 2001 3:39 PM
To: sunhelp at sunhelp.org
Subject: [SunHELP] script challenge



Gurus, 

I have an input file which has the following data in it, 

############ 20010216_200000 ########### 
220 
190 
180 
190 
210 
180 
190 
190 
190 
180 
The Average time for this ping is: 192 
######################################## 


############ 20010216_203000 ########### 
 The listner is down at this time 
######################################## 

What I would like to do is associate the "Average" time with the collection
time and put it in a seperate file ignoring the rest, in the following
format,

2001::02::16::192 

I hope I am clear on this question. 
Any help or suggestion will be greatly appreciated. 
TIA 




------_=_NextPart_001_01C09C64.1E512170
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">
<TITLE>script challenge</TITLE>

<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR></HEAD>
<BODY>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D302420600-22022001>Hello=20
Every one ,</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D302420600-22022001>Thanks=20
for guidance and right direction.</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D302420600-22022001></SPAN></FONT> </DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D302420600-22022001>I=20
figured the way of doing it. Below is my solution going completely =
"awk"=20
way</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D302420600-22022001></SPAN></FONT> </DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D302420600-22022001>+++++++++++++++++++++++++++</SPAN></FONT></DI=
V>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D302420600-22022001>BEGIN=20
{<BR>       =20
NEW_LIST=3D0<BR>}<BR>{<BR>        if =
($0 ~=20
/^##* [0-9]*/)=20
{<BR>           &=
nbsp;   =20
NEW_LIST=3D1;<BR>         &=
nbsp;     =20
TIMESTAMP=3D$2;<BR>#        &nbs=
p;     =20
print $0;<BR>        =
}</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D302420600-22022001>        =
while=20
(NEW_LIST =3D=3D 1)=20
{<BR>           &=
nbsp;   =20
if (getline !=3D 1)=20
break;<BR>          &n=
bsp;    =20
if ($0 ~=20
/listner/)<BR>         &nbs=
p;           &nbs=
p; =20
NEW_LIST =3D=20
0;<BR>           =
    =20
else if ($0 ~ /Average/)=20
{<BR>           &=
nbsp;            =

NEW_LIST =3D=20
0;<BR>           =
            =
=20
AVG_TIME =3D=20
$8;<BR>          &nbsp=
;           &nbsp=
;=20
printf ("%s%d\n", TIMESTAMP,=20
AVG_TIME);<BR>         &nbs=
p;     =20
}<BR>       =20
}<BR>}<BR>++++++++++++++++++++++++++++++++++++++++++++++</SPAN></FONT></=
DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D302420600-22022001></SPAN></FONT> </DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D302420600-22022001>#cat=20
inputfile.txt | awk -f script.awk</SPAN></FONT></DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN=20
class=3D302420600-22022001></SPAN></FONT> </DIV>
<DIV><FONT color=3D#0000ff face=3DArial size=3D2><SPAN =
class=3D302420600-22022001>will=20
do the job. For further processing, call the above in a seperate shell =
script=20
and go from there.</SPAN></FONT></DIV>
<DIV> </DIV>
<BLOCKQUOTE style=3D"MARGIN-RIGHT: 0px">
  <DIV align=3Dleft class=3DOutlookMessageHeader dir=3Dltr><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> Michael Marziani=20
  [mailto:michael.marziani at onfiber.com]<BR><B>Sent:</B> Wednesday, =
February 21,=20
  2001 6:02 PM<BR><B>To:</B> 'sunhelp at sunhelp.org'<BR><B>Subject:</B> =
RE:=20
  [SunHELP] script challenge<BR><BR></DIV></FONT>
  <DIV><SPAN class=3D257575522-21022001><FONT color=3D#0000ff =
face=3DArial size=3D2>I=20
  wouldn't insult your intelligence by writing the script for you, =
because this=20
  would be extremely easy to do in Perl (my scripting language of =
choice). =20
  Simply read the file in, grab the first line and snag and parse =
the date,=20
  then look for the line with /Average/ in it, grab the average =
ping, put=20
  them together how you want and append the output=20
  to your other file.  The first 2 chapters of most any =
perl book=20
  (or web tutorial) will give you the info to get this done in short=20
  order.</FONT></SPAN></DIV>
  <DIV><SPAN class=3D257575522-21022001><FONT color=3D#0000ff =
face=3DArial=20
  size=3D2></FONT></SPAN> </DIV>
  <DIV><SPAN class=3D257575522-21022001><FONT color=3D#0000ff =
face=3DArial=20
  size=3D2>-Mike</FONT></SPAN></DIV>
  <DIV><SPAN class=3D257575522-21022001></SPAN><FONT =
face=3DTahoma><FONT=20
  size=3D2><SPAN class=3D257575522-21022001><FONT color=3D#0000ff=20
  face=3DArial> </FONT></SPAN></FONT></FONT></DIV>
  <DIV><FONT face=3DTahoma><FONT size=3D2><SPAN=20
  class=3D257575522-21022001></SPAN></FONT></FONT> </DIV>
  <DIV><FONT face=3DTahoma><FONT size=3D2><SPAN=20
  class=3D257575522-21022001> </SPAN>-----Original=20
  Message-----<BR><B>From:</B> Naser Ali=20
  [mailto:Ali.Naser at irs.gov]<BR><B>Sent:</B> Wednesday, February 21, =
2001 3:39=20
  PM<BR><B>To:</B> sunhelp at sunhelp.org<BR><B>Subject:</B> [SunHELP] =
script=20
  challenge<BR><BR></DIV></FONT></FONT>
  <BLOCKQUOTE>
    <P><FONT color=3D#000000 face=3D"Comic Sans MS" =
size=3D2>Gurus,</FONT> </P>
    <P><FONT color=3D#000000 face=3D"Comic Sans MS" size=3D2>I have an =
input file=20
    which has the following data in it,</FONT> </P>
    <P><FONT color=3D#000000 face=3D"Comic Sans MS" =
size=3D2>############=20
    20010216_200000 ###########</FONT> <BR><FONT color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>220</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>190</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>180</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>190</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>210</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>180</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>190</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>190</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>190</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>180</FONT> <BR><FONT =
color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2>The Average time for this ping is: =
192</FONT>=20
    <BR><FONT color=3D#000000 face=3D"Comic Sans MS"=20
    size=3D2>########################################</FONT> </P><BR>
    <P><FONT color=3D#000000 face=3D"Comic Sans MS" =
size=3D2>############=20
    20010216_203000 ###########</FONT> <BR><FONT color=3D#000000=20
    face=3D"Comic Sans MS" size=3D2> The listner is down at this =
time</FONT>=20
    <BR><FONT color=3D#000000 face=3D"Comic Sans MS"=20
    size=3D2>########################################</FONT> </P>
    <P><FONT color=3D#000000 face=3D"Comic Sans MS" size=3D2>What I =
would like to do=20
    is associate the "Average" time with the collection time and put it =
in a=20
    seperate file ignoring the rest, in the following =
format,</FONT></P>
    <P><FONT color=3D#000000 face=3D"Comic Sans MS" =
size=3D2>2001::02::16::192</FONT>=20
    </P>
    <P><FONT color=3D#000000 face=3D"Comic Sans MS" size=3D2>I hope I =
am clear on this=20
    question.</FONT> <BR><FONT color=3D#000000 face=3D"Comic Sans MS" =
size=3D2>Any=20
    help or suggestion will be greatly appreciated.</FONT> <BR><FONT=20
    color=3D#000000 face=3D"Comic Sans MS" size=3D2>TIA</FONT>=20
</P><BR><BR></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>

------_=_NextPart_001_01C09C64.1E512170--



More information about the SunHELP mailing list