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

Help needed in searching a pattern from a mails.

Expand Messages
  • prasadjoshi_aol
    Hi All, This is what I am doing. In my company, we need to download some builds from a server. These builds are uploaded during night at US. As soon as they
    Message 1 of 2 , Jul 4, 2006
      Hi All,

      This is what I am doing.
      In my company, we need to download some builds from a server. These
      builds are uploaded during night at US. As soon as they upload build,
      we get a mail something like this.

      <START OF MAIL>

      From: release-eng@... [mailto:release-eng@...]
      To: release-eng [DL UNIX]
      Subject: PUNEVAULT.VXINDIA.VERITAS.COM: Replication hpux
      5.0-2006-06-09a completed successfully!

      The source location on SVLVAULT is:
      /re/release_train/hpux/5.0/alpha/5.0-2006-06-09a
      The destination location on PUNEVAULT.VXINDIA.VERITAS.COM is:
      /re/release_train/hpux/5.0/alpha/5.0-2006-06-09a
      For more information please refer to log file at
      /re/bin/replication/replicasuccess/log.1069

      <END OF MAIL>

      These builds are of size near about 2 GB. If we do it mannually it
      takes around 3 to 4 hours to complete.


      Now, I want to automate this procedure. I have written a perl script
      which contacts POP3 server. Searches for mail from perticular mail ID.

      But, still I need to find
      1. Server Name. (PUNEVAULT.VXINDIA.VERITAS.COM)
      2. Build name (5.0-2006-06-09a)
      3. Path on the remote server.

      I am not good at PERL scripting, I want to do it in an efficient
      manner. Can anyone help?

      Script to download the build file by taring and gziping is already ready.

      Thanks and regards,
      Prasad.
    • Damien Carbery
      ... ready. ... If the mail is in a single string e.g. $mailcontents, you could parse it easily: my $mailcontents = From: release-eng@...
      Message 2 of 2 , Jul 5, 2006
        --- In perl-beginner@yahoogroups.com, "prasadjoshi_aol"
        <prasad_joshi1@...> wrote:
        >
        > Hi All,
        >
        > This is what I am doing.
        > In my company, we need to download some builds from a server. These
        > builds are uploaded during night at US. As soon as they upload build,
        > we get a mail something like this.
        >
        > <START OF MAIL>
        >
        > From: release-eng@... [mailto:release-eng@...]
        > To: release-eng [DL UNIX]
        > Subject: PUNEVAULT.VXINDIA.VERITAS.COM: Replication hpux
        > 5.0-2006-06-09a completed successfully!
        >
        > The source location on SVLVAULT is:
        > /re/release_train/hpux/5.0/alpha/5.0-2006-06-09a
        > The destination location on PUNEVAULT.VXINDIA.VERITAS.COM is:
        > /re/release_train/hpux/5.0/alpha/5.0-2006-06-09a
        > For more information please refer to log file at
        > /re/bin/replication/replicasuccess/log.1069
        >
        > <END OF MAIL>
        >
        > These builds are of size near about 2 GB. If we do it mannually it
        > takes around 3 to 4 hours to complete.
        >
        >
        > Now, I want to automate this procedure. I have written a perl script
        > which contacts POP3 server. Searches for mail from perticular mail ID.
        >
        > But, still I need to find
        > 1. Server Name. (PUNEVAULT.VXINDIA.VERITAS.COM)
        > 2. Build name (5.0-2006-06-09a)
        > 3. Path on the remote server.
        >
        > I am not good at PERL scripting, I want to do it in an efficient
        > manner. Can anyone help?
        >
        > Script to download the build file by taring and gziping is already
        ready.
        >
        > Thanks and regards,
        > Prasad.
        >

        If the mail is in a single string e.g. $mailcontents, you could parse
        it easily:

        my $mailcontents = 'From: release-eng@... [mailto:release-eng@...]
        --snip--
        /re/bin/replication/replicasuccess/log.1069';

        sub ParseBuildInfo( $ )
        {
        # $_[0] is the data passed to the function.
        if ( $_[0] =~ /\s(\S+) completed successfully.*The destination
        location on (\S+) is:\s+(\S+)\s/s )
        {
        print "INFO: Server Name: $2\nBuild name: $1\nPath: $3\n";
        return ( $2, $1, $3 );
        }
        else
        {
        print "ERROR: Unable to extract the server and directory.\n";
        return ();
        }
        }

        # Call the function and get the server/build/path info in return.
        my ( $Server, $BuildName, $Path ) = ParseBuildInfo( $mailcontents );
        print "$Server, $BuildName, $Path\n";

        \s matches a space character (space, tab, \r, \n and \f)
        \S matches a non-space character (everything bug space chars). Adding
        the '+' matches at least one non-space character.
        The brackets i.e (\S+) extracts the parts matched and stores them in
        $1, $2 etc.

        This function might drop into your current code.
        Note: the code indenting might be lost as I posted this from the
        groups.yahoo.com web interface.
      Your message has been successfully submitted and would be delivered to recipients shortly.