Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Id like to be able to zip up a directory, or part of a directory and then email the file, or maybe FTP it to somewhere. Is this possible?

Ive read about FTP'ing, so that seems possible, but its the zipping and attaching to an email that Im uncertain of.

Any help would be appreciated.

Replies are listed 'Best First'.
Re: Zip up and email
by bikeNomad (Priest) on Aug 10, 2001 at 18:56 UTC
Re: Zip up and email
by mexnix (Pilgrim) on Aug 10, 2001 at 18:58 UTC
    Take a look at Net::FTP and Archive::Zip (Archive::Zip written by our own bikeNomad). You should find what you need there.

    __________________________________________________
    <moviequote name="Hackers">
    The Plague: [...]Well let me explain the New World Order. Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo!
    </moviequote>

    mexnix.perlmonk.org

Re: Zip up and email
by suaveant (Parson) on Aug 10, 2001 at 19:05 UTC
    First question... windows or unix? I know how to do it in Unix... the way I know requires you have the zip command for unix... to FTP you can use Net::FTP
    use Net::FTP; `/usr/bin/zip -r zipfile.zip /directory/to/zip/`; #-r means recurse my $ftp = Net::FTP->new("some.host.name", Debug => 0); $ftp->login("anonymous",'me@here.there'); $ftp->cwd("/incoming"); $ftp->put("zipfile.zip"); $ftp->quit;
    or to email you can use Mail::Sender
    use Mail::Sender; `/usr/bin/zip -r zipfile.zip /directory/to/zip/`; #-r means recurse my $sender = new Mail::Sender {smtp => 'mail.yourdomain.com', from => 'your@address.com'}; $sender->MailFile({to => 'some@address.com', subject => 'Here is the file', msg => "your message here.", file => 'zipfile.zip'});
    I believe both of these modules will work in windows as well... but the zip command would be different...

                    - Ant
                    - Some of my best work - Fish Dinner

      Ok, thanks for your suggestions.

      I should also mention that this is to be used on a web server as part of a cgi program.

      Will this make a difference?
        If it takes a long time (like more than a minute) you might want to background the process... otherwise, no.

                        - Ant
                        - Some of my best work - Fish Dinner