Hi ...

Well Im sorry for my late reply but here is my final script ( wrotte by me )
of solve this problem ...

#!/usr/bin/perl

#Modulos
use MIME::Lite;
use warnings;
use strict;

#################################################################
################        Configuration
##################################
#################################################################
#Nombre del servidor de correo revisar /etc/posfix
my $mail_host='servidor.mx';
#Ruta del directorio donde se encuentran los attach del email
my $attach_path="/home/user/To\-Email";
#Ruta del directorio log que CaptureHPC crea
my $log_path="/home/user/To\-Email/log";

##################################################################################
################        Funciones
##################################
##################################################################################

sub SendEmailwAttach{
        print "Estoy aqui .... tratando de enviar el mail\n";
        my $attache= shift(@_);
        print "attache=$attache";
        my $msg=new MIME::Lite;
        $msg = MIME::Lite->new(
                    From    =>  '[EMAIL PROTECTED]',
                    To      =>  '[EMAIL PROTECTED]',
                    Cc     =>   '[EMAIL PROTECTED]',
                    Subject =>  'Reporte de Urls Maliciosas...',
                    Type    =>  'multipart/mixed'
        );
        my $pwd=`pwd`;
        print $pwd,"\n";
        my @data=`./hpc-log-parser-english.sh $log_path`;
        ### Aqui coloca el texto que deseas !!!!:
        ### (Note that "attach" has same arguments as "new"):
        $msg->attach(
                Type     =>'TEXT',
                Data     => "@data"
        ) or die "Error: during put data on Attach ... $!";
        chomp($attache);
        ### Aqui agrega el archivo que quieres:
        $msg->attach(
                Type     => 'x-gzip',
                Path     => "gzip < $attache |",
                ReadNow  => 1,
                Filename => 'backup.tgz',
                Disposition => 'attachment'
        ) or die "ERROR: here in the attach ...$!";

        #Enviando el Email
        MIME::Lite->send('smtp',$mail_host,Timeout=>60);
        $msg->send;
        print "Listoooooo ....\n";
}

sub limpia_Attach{

        my @something=`ls $attach_path`;
        print "numero: $#something\n";
        if ( @something ){
                print "Tiene algo\n";
                print @something,"\n";
                foreach (@something){
                        `rm -rf $_`;
                }
                print "ok ...\n";
        }else{
                print "Esta vacio\n";
        }

}
sub Main{

        my $aux;

        my @tmp=`ls $attach_path`;
        foreach (@tmp){
                if ($_ =~ /backup*/){
                        $aux=$_;
                }
        }

        my $file="$attach_path/$aux";
        print "archivo=$file";

        if ( $file ){
                print "Enviando Email w attach\n";
                SendEmailwAttach($file);
        }else{
                print "sorry, es un directorio, $aux\n";
        }
}

Main();
limpia_Attach();


  I reply and post this script if somebody sometime need help in this kind
of problems, and maybe works or help some other people.

Thanks all the people who reply all my latest post and give time to this
problem, thanks for all



On Fri, Jun 20, 2008 at 10:09 AM, David Romero <[EMAIL PROTECTED]> wrote:

> Use the Mail::Sender Module, is to easy with it
>
>  (ref ($sender->MailFile(
>  {to =>'[EMAIL PROTECTED]', subject => 'this is a test',
>   msg => "Hi Johnie.\nI'm sending you the pictures you wanted.",
>   file => 'image1.jpg,image2.jpg'
>  }))
>  and print "Mail sent OK."
>  )
>  or die "$Mail::Sender::Error\n";
>
>
>
>
>
> On Fri, Jun 20, 2008 at 10:04 AM, Rob Dixon <[EMAIL PROTECTED]> wrote:
> > Armin Garcia wrote:
> >>
> >> well i have some problems again, thats my new code:
> >>
> >>
> >> #!/usr/bin/perl -w
> >
> > Drop the -w qualifer from this line. It is best done with 'use warnings'
> that
> > you have below.
> >
> > Also
> >
> >  use strict;
> >  use warnings;
> >
> > here instead of after including MIME::Lite.
> >
> >> #Modulos
> >> use MIME::Lite;
> >> use warnings;
> >> use strict;
> >>
> >>
> ##################################################################################
> >> ################        Configuration
> >> ##################################
> >>
> ##################################################################################
> >>
> >> #Ruta del directorio donde se encuentran los attach del email
> >> $attach_path="/home/agarcia/HoneyClient/To\-Email";
> >
> > Once you have used strict, all variables need declaring using my.
> >
> > There is no need to escape the hyphen here, and also since you aren't
> using
> > interpolation it's best to use single quotes.
> >
> >  my $attach_path = '/home/agarcia/HoneyClient/To-Email';
> >
> >> #log path
> >> $log_path="/home/agarcia/HoneyClient/To\-Email/log";
> >>
> >> #ruta donde se localiza el script para parsear las bitacoras de
> CaptureHPC
> >>
> $hpc_log_home="/usr/local/Honeyclient/HoneyClient3/ScriptHoney/capture-server-2.1.0-300";
> >>
> >>
> ##################################################################################
> >> ################        Funciones
> >> ##################################
> >>
> ##################################################################################
> >>
> >> sub SendEmailwAttach{
> >>         print "Estoy aqui .... tratando de enviar el mail\n";
> >>         my $attache= shift(@_);
> >>         print "attache=$attache";
> >>         $msg=new MIME::Lite;
> >>         $msg = MIME::Lite->new(
> >>                     From    =>  '[EMAIL PROTECTED]',
> >>                     To      =>  '[EMAIL PROTECTED]',
> >>         #            Cc     =>  '[EMAIL PROTECTED]',
> >>                     Subject =>  'Reporte de Urls Maliciosas...',
> >>                     Type    =>  'multipart/mixed'
> >>         );
> >>
> >>         @data=`./hpc-log-parser.sh $log_path`;
> >
> > I don't know what this does, but it's likely to be better to write it in
> Perl.
> >
> >>         print @data;
> >>         ### Aqui coloca el texto que deseas !!!!:
> >>         ### (Note that "attach" has same arguments as "new"):
> >>         $msg->attach(
> >>                 Type     =>'TEXT',
> >>                 Data     => "@data"
> >>         );
> >>
> >>         ### Aqui agrega el archivo que quieres:
> >>         $msg->attach(
> >>                * Type     => 'x-gzip',
> >>                 Path     => "gzip < $attache |", <------------- i think
> here
> >> is the problem but i dont know why*
> >>                 ReadNow  => 1,
> >>                 Filename => 'backup.tgz',
> >>                 Disposition => 'attachment'
> >>         ) or die "ERROR: here in the attach ...$!";
> >>
> >>         print "Listoooooo ....\n";
> >> }
> >>
> >> sub Main{
> >>
> >>         my $aux;
> >>
> >>         @tmp=`ls $attach_path`;
> >>         foreach (@tmp){
> >>                 if ($_ =~ /backup*/){
> >>                         $aux=$_;
> >>                 }
> >>         }
> >>
> >>         $file="$attach_path/$aux";
> >>         print "archivo=$file";
> >>
> >>         if ( $file ){
> >>                 print "Enviando Email w attach\n";
> >>                 SendEmailwAttach($file);
> >>         }else{
> >>                 print "sorry, es un directorio, $aux\n";
> >>         }
> >> }
> >>
> >> Main();
> >
> > This looks like a C programming habit. It's more conventional in Perl to
> put all
> > the main code at the top of the program and not wrap it as a subroutine.
> >
> >>
> >> Well the problem is i recibe the next output on my terminal when i
> execute
> >> this script
> >>
> >> *Unsuccessful stat on filename containing newline at
> >> /usr/local/share/perl/5.8.8/MIME/Lite.pm line 1549.
> >>
> >> I dont understand what does mean ... :s
> >>
> >> when first, only i cant attach files using a variable, this is my
> problem,
> >> if i put a file with the correct name and path, no problem, but my
> problem
> >> is in this directory this file changes with the time
> >>
> >> I hope somebody helps me, and if you have some tips, all of them are
> welcome
> >> !!!
> >> *
> >
> > We can't help you much further as you haven't posted the code that's
> causing you
> > problems. Try implementing the suggestions above and see where that leads
> you.
> >
> > Rob
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > http://learn.perl.org/
> >
> >
> >
>
>
>
> --
> David Romero
> www.factufacil.com.mx
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

Reply via email to