Ftp via Perl cron job

Discussion in 'Perl Misc' started by Bill H, Sep 26, 2006.

  1. Bill H

    Bill H Guest

    I have a Perl program that processes a file, saves the results in a new
    file and then need to ftp that file to a different server, can anyone
    point me to some documentation or a module / source on how I can
    accomplish the ftp portion via Perl?

    Thanks

    Bill H
    Bill H, Sep 26, 2006
    #1
    1. Advertising

  2. Bill H

    David Squire Guest

    Bill H wrote:
    > I have a Perl program that processes a file, saves the results in a new
    > file and then need to ftp that file to a different server, can anyone
    > point me to some documentation or a module / source on how I can
    > accomplish the ftp portion via Perl?


    How about going to search.cpan.org and searching for FTP?


    DS
    David Squire, Sep 26, 2006
    #2
    1. Advertising

  3. Bill H

    Guest

    Bill H wrote:
    > I have a Perl program that processes a file, saves the results in a new
    > file and then need to ftp that file to a different server, can anyone
    > point me to some documentation or a module / source on how I can
    > accomplish the ftp portion via Perl?


    #!/usr/bin/perl
    use strict;
    use Net::FTP;

    # Step 1 - set variables to your specifications
    my ($server, $username, $password, $directory, $holdfile);

    # Step 2 -- FTP to server and download the holdfile
    my $ftp = Net::FTP->new($server, Debug => 0) or die "Cannot connect,
    $@";
    $ftp->login($username, $password) or die "Cannot login ", $ftp->
    message;
    $ftp->cwd($dirctory) or die "Cannot change working directory ",
    $ftp->message;
    $ftp->ascii;
    $ftp->get($holdfile) or die "Cannot get $holdfile ", $ftp->message;
    $ftp->quit;

    exit();


    CC
    , Sep 26, 2006
    #3
  4. Bill H

    Bill H Guest

    wrote:
    > Bill H wrote:
    > > I have a Perl program that processes a file, saves the results in a new
    > > file and then need to ftp that file to a different server, can anyone
    > > point me to some documentation or a module / source on how I can
    > > accomplish the ftp portion via Perl?

    >
    > #!/usr/bin/perl
    > use strict;
    > use Net::FTP;
    >
    > # Step 1 - set variables to your specifications
    > my ($server, $username, $password, $directory, $holdfile);
    >
    > # Step 2 -- FTP to server and download the holdfile
    > my $ftp = Net::FTP->new($server, Debug => 0) or die "Cannot connect,
    > $@";
    > $ftp->login($username, $password) or die "Cannot login ", $ftp->
    > message;
    > $ftp->cwd($dirctory) or die "Cannot change working directory ",
    > $ftp->message;
    > $ftp->ascii;
    > $ftp->get($holdfile) or die "Cannot get $holdfile ", $ftp->message;
    > $ftp->quit;
    >
    > exit();
    >
    >
    > CC


    Thanks for all the information. After posting this quested I started
    searching and came across the Net::FTP way of doing it. You posting the
    same information makes me feel better about using it. Any idea how to
    use secure ftp?

    Bill H
    Bill H, Sep 26, 2006
    #4
  5. Bill H

    J. Gleixner Guest

    Bill H wrote:
    > Thanks for all the information. After posting this quested I started
    > searching and came across the Net::FTP way of doing it. You posting the
    > same information makes me feel better about using it. Any idea how to
    > use secure ftp?


    Whenever you're looking for a module, always start with
    CPAN ( http://search.cpan.org/ ) or at least use your
    favorite Internet search engine. If you had, you'd have
    found your answer without having to post and wait for
    a response.
    J. Gleixner, Sep 28, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Berger

    net/ftp works manually, fails via cron

    Daniel Berger, Sep 23, 2005, in forum: Ruby
    Replies:
    3
    Views:
    112
    Daniel Berger
    Sep 23, 2005
  2. D. Buck
    Replies:
    2
    Views:
    482
    D. Buck
    Jun 29, 2004
  3. goooo

    Cron Job & Perl

    goooo, Mar 21, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    161
    Joe Smith
    Mar 22, 2005
  4. Bob Anastasia

    Cron Job through Perl

    Bob Anastasia, Jun 26, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    117
    Ted Zlatanov
    Jun 26, 2006
  5. Bucker

    Runs Fine In Perl :: Not As Cron Job

    Bucker, Jan 15, 2007, in forum: Perl Misc
    Replies:
    6
    Views:
    186
    -berlin.de
    Jan 17, 2007
Loading...

Share This Page