Loading ...
Sorry, an error occurred while loading the content.

Re: parse email

Expand Messages
  • Bryan Irvine
    ok with this command grep Received 10600* | awk {print $5} | grep [ .test.txt i get a file containing ip addresses that looks like this [217.129.17.33])
    Message 1 of 6 , Aug 4, 2003
    • 0 Attachment
      ok with this command

      grep Received 10600* | awk '{print $5}'| grep "\[" > .test.txt

      i get a file containing ip addresses that looks like this

      [217.129.17.33])
      [64.70.30.155])
      [210.83.246.142])
      [64.235.238.165])
      [80.26.150.100])
      [24.141.221.250])
      [218.188.52.74])
      [151.199.32.206])
      [68.46.70.74])
      [68.97.39.32])
      [200.253.37.4])


      Is there a way in perl to remove the first character, and the last 2
      characters?

      --Bryan


      > I have a list of about 7500 email messages that I would like to block
      > the sending server and add them to my blacklist.
      >
      > What I'd like is a perl script to generate a file list that looks
      > somthing like
      >
      > Subject: $subject of the message
      > Ip to block: $IP.ADDRESS.TO.BLOCK
      >
      > From headers that look like this:
      > Received: from wimco.wimco-nv.wimco-nv.com (unknown [198.93.176.8]) by
      > mail2.horvitznewspapers.net (Postfix) with ESMTP id
      > 35B7A1CBC21 for
      > <webmaster@e...>; Sat, 8 Mar 2003 01:59:00
      > -0800 (PST)
      > Received: from in-mta4.plasa.com ([216.25.173.186]) by
      > wimco.wimco-nv.wimco-nv.com with Microsoft
      > SMTPSVC(5.0.2195.5329); Sun, 2
      > Mar 2003 05:30:36 -0400
      > Message-ID: <000075ce6b37$0000629c$0000661d@i...>
      > To: <Undisclosed Recipients@h...>
      > From: suzanne9337@p...
      > Subject: Shop For A Loan With Over 2000 Lenders!
      > SNHHFE
      >
      >
      > --Bryan
    • Damien Carbery
      ... Modify your awk code to get the data you want: grep Received 10600* | awk {substr($5,2,length($5)-3)} | grep [ .test.txt
      Message 2 of 6 , Aug 5, 2003
      • 0 Attachment
        --- In perl-beginner@yahoogroups.com, "Bryan Irvine"
        <bryan.irvine@k...> wrote:
        > ok with this command
        >
        > grep Received 10600* | awk '{print $5}'| grep "\[" > .test.txt
        >
        > i get a file containing ip addresses that looks like this
        >
        > [217.129.17.33])
        > [64.70.30.155])
        > [210.83.246.142])
        > [64.235.238.165])
        > [80.26.150.100])
        > [24.141.221.250])
        > [218.188.52.74])
        > [151.199.32.206])
        > [68.46.70.74])
        > [68.97.39.32])
        > [200.253.37.4])
        >
        >
        > Is there a way in perl to remove the first character, and the last 2
        > characters?
        >
        > --Bryan
        >
        >
        > > I have a list of about 7500 email messages that I would like to block
        > > the sending server and add them to my blacklist.
        > >
        > > What I'd like is a perl script to generate a file list that looks
        > > somthing like
        > >
        > > Subject: $subject of the message
        > > Ip to block: $IP.ADDRESS.TO.BLOCK
        > >
        > > From headers that look like this:
        > > Received: from wimco.wimco-nv.wimco-nv.com (unknown [198.93.176.8]) by
        > > mail2.horvitznewspapers.net (Postfix) with ESMTP id
        > > 35B7A1CBC21 for
        > > <webmaster@e...>; Sat, 8 Mar 2003 01:59:00
        > > -0800 (PST)
        > > Received: from in-mta4.plasa.com ([216.25.173.186]) by
        > > wimco.wimco-nv.wimco-nv.com with Microsoft
        > > SMTPSVC(5.0.2195.5329); Sun, 2
        > > Mar 2003 05:30:36 -0400
        > > Message-ID: <000075ce6b37$0000629c$0000661d@i...>
        > > To: <Undisclosed Recipients@h...>
        > > From: suzanne9337@p...
        > > Subject: Shop For A Loan With Over 2000 Lenders!
        > > SNHHFE
        > >
        > >
        > > --Bryan

        Modify your awk code to get the data you want:
        grep Received 10600* | awk '{substr($5,2,length($5)-3)}'| grep "\[" >
        .test.txt
      • Hans Ginzel
        ... Or do it all in perl (perldoc perlrun, perldoc perlre, perldoc perlop s/// ): perl -ne /Received 1060/ and / [( d{1,3}(?: . d{1,3}){3})) ] )/ and print
        Message 3 of 6 , Aug 5, 2003
        • 0 Attachment
          On Mon, Aug 04, 2003 at 05:43:47PM -0000, Bryan Irvine wrote:
          > grep Received 10600* | awk '{print $5}'| grep "\[" > .test.txt
          >
          > [217.129.17.33])
          > [218.188.52.74])
          >
          > Is there a way in perl to remove the first character, and the last 2
          > characters?

          For this particular you can use sed:

          | sed -e 's/^.//' -e 's/..$//' >out.txt

          Or do it all in perl (perldoc perlrun, perldoc perlre, perldoc perlop
          "s///"):

          perl -ne '/Received 1060/ and /\[(\d{1,3}(?:\.\d{1,3}){3}))\]\)/
          and print "$1\n"' > out.txt

          Probably use an easier regexp
          /\[ # match `['
          ( # store next into $1
          [ # match class of
          \d # digit
          \. # or dot
          ]
          + # once or moretimes
          )
          \] # match `]'
          \) # match `)'
          /x # extended syntax of REs
          # perldoc perlre

          --
          Hans
        • CARTER Anthony
          functions: substr($VAR, -3) = ; gives $VAR= test whereas substr($VAR, 3)= ; gives $VAR= t123 so for you, easy way: if variable = $VAR then, substr($VAR,
          Message 4 of 6 , Aug 5, 2003
          • 0 Attachment
            functions:


            substr($VAR, -3) ="";

            gives

            $VAR='test'

            whereas

            substr($VAR, 3)="";

            gives

            $VAR= 't123'


            so for you, easy way:

            if variable = $VAR then,

            substr($VAR, 1) ="";
            substr($VAR, -2) = "";

            will give you your result desired.

            Anthony



            -----Original Message-----
            From: Hans Ginzel [mailto:hans@...]
            Sent: 05 August 2003 12:21
            To: perl-beginner@yahoogroups.com
            Subject: Re: [PBML] Re: parse email


            On Mon, Aug 04, 2003 at 05:43:47PM -0000, Bryan Irvine wrote:
            > grep Received 10600* | awk '{print $5}'| grep "\[" > .test.txt
            >
            > [217.129.17.33])
            > [218.188.52.74])
            >
            > Is there a way in perl to remove the first character, and the last 2
            > characters?

            For this particular you can use sed:

            | sed -e 's/^.//' -e 's/..$//' >out.txt

            Or do it all in perl (perldoc perlrun, perldoc perlre, perldoc perlop
            "s///"):

            perl -ne '/Received 1060/ and /\[(\d{1,3}(?:\.\d{1,3}){3}))\]\)/
            and print "$1\n"' > out.txt

            Probably use an easier regexp
            /\[ # match `['
            ( # store next into $1
            [ # match class of
            \d # digit
            \. # or dot
            ]
            + # once or moretimes
            )
            \] # match `]'
            \) # match `)'
            /x # extended syntax of REs
            # perldoc perlre

            --
            Hans


            Yahoo! Groups Sponsor

            ADVERTISEMENT

            <http://rd.yahoo.com/M=244522.3656190.4921519.1261774/D=egroupweb/S=17050069
            51:HM/A=1595053/R=0/SIG=124mh1h7k/*http://ashnin.com/clk/muryutaitakenattogy
            o?YH=3656190&yhad=1595053> Click Here!

            <http://us.adserver.yahoo.com/l?M=244522.3656190.4921519.1261774/D=egroupmai
            l/S=:HM/A=1595053/rand=317723023>

            Unsubscribing info is here:
            http://help.yahoo.com/help/us/groups/groups-32.html
            <http://help.yahoo.com/help/us/groups/groups-32.html>

            Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
            <http://docs.yahoo.com/info/terms/> .




            [Non-text portions of this message have been removed]
          • CARTER Anthony
            Sorry, I forgot to say that initially $VAR= test123 also, the - in the substr indicates from end, whereas a positive number indicates from beginning. Anthony
            Message 5 of 6 , Aug 5, 2003
            • 0 Attachment
              Sorry, I forgot to say that initially $VAR="test123"

              also, the - in the substr indicates from end, whereas a positive number
              indicates from beginning.

              Anthony

              -----Original Message-----
              From: CARTER Anthony
              Sent: 05 August 2003 12:48
              To: 'perl-beginner@yahoogroups.com'
              Subject: RE: [PBML] Re: parse email


              functions:


              substr($VAR, -3) ="";

              gives

              $VAR='test'

              whereas

              substr($VAR, 3)="";

              gives

              $VAR= 't123'


              so for you, easy way:

              if variable = $VAR then,

              substr($VAR, 1) ="";
              substr($VAR, -2) = "";

              will give you your result desired.

              Anthony



              -----Original Message-----
              From: Hans Ginzel [mailto:hans@...]
              Sent: 05 August 2003 12:21
              To: perl-beginner@yahoogroups.com
              Subject: Re: [PBML] Re: parse email


              On Mon, Aug 04, 2003 at 05:43:47PM -0000, Bryan Irvine wrote:
              > grep Received 10600* | awk '{print $5}'| grep "\[" > .test.txt
              >
              > [217.129.17.33])
              > [218.188.52.74])
              >
              > Is there a way in perl to remove the first character, and the last 2
              > characters?

              For this particular you can use sed:

              | sed -e 's/^.//' -e 's/..$//' >out.txt

              Or do it all in perl (perldoc perlrun, perldoc perlre, perldoc perlop
              "s///"):

              perl -ne '/Received 1060/ and /\[(\d{1,3}(?:\.\d{1,3}){3}))\]\)/
              and print "$1\n"' > out.txt

              Probably use an easier regexp
              /\[ # match `['
              ( # store next into $1
              [ # match class of
              \d # digit
              \. # or dot
              ]
              + # once or moretimes
              )
              \] # match `]'
              \) # match `)'
              /x # extended syntax of REs
              # perldoc perlre

              --
              Hans


              Yahoo! Groups Sponsor

              ADVERTISEMENT

              <
              http://rd.yahoo.com/M=244522.3656190.4921519.1261774/D=egroupweb/S=17050069
              <http://rd.yahoo.com/M=244522.3656190.4921519.1261774/D=egroupweb/S=17050069
              >
              51:HM/A=1595053/R=0/SIG=124mh1h7k/*
              http://ashnin.com/clk/muryutaitakenattogy
              <http://ashnin.com/clk/muryutaitakenattogy>
              o?YH=3656190&yhad=1595053> Click Here!

              <
              http://us.adserver.yahoo.com/l?M=244522.3656190.4921519.1261774/D=egroupmai
              <http://us.adserver.yahoo.com/l?M=244522.3656190.4921519.1261774/D=egroupmai
              >
              l/S=:HM/A=1595053/rand=317723023>

              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html
              <http://help.yahoo.com/help/us/groups/groups-32.html>
              < http://help.yahoo.com/help/us/groups/groups-32.html
              <http://help.yahoo.com/help/us/groups/groups-32.html> >

              Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
              < http://docs.yahoo.com/info/terms/ <http://docs.yahoo.com/info/terms/> > .




              [Non-text portions of this message have been removed]



              Yahoo! Groups Sponsor

              ADVERTISEMENT

              <http://rd.yahoo.com/M=251812.3170658.4537139.1261774/D=egroupweb/S=17050069
              51:HM/A=1693353/R=0/SIG=11t71ok4g/*http://www.netflix.com/Default?mqso=60178
              294&partid=3170658> click here

              <http://us.adserver.yahoo.com/l?M=251812.3170658.4537139.1261774/D=egroupmai
              l/S=:HM/A=1693353/rand=435118235>

              Unsubscribing info is here:
              http://help.yahoo.com/help/us/groups/groups-32.html
              <http://help.yahoo.com/help/us/groups/groups-32.html>

              Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
              <http://docs.yahoo.com/info/terms/> .




              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.