I need to autmate an ftp session where if the particular file I am looking for on the ftp server is newer than the file I have on my local machine I want to download it. Before I can get to the part where I compare dates (I'm looking for suggestions please), I can't even get a decent session to run because the server won't do cwd. I do not have any control over the server side at all.
I used Net::FTP, but the ftp server does not support the cwd command Net::FTP needs to work. Any suggestions?
*NOTE Net::FTP does not support the cd command either.
#!/usr/bin/perl -w # ----------------------------------------------------------- # FTP script # ----------------------------------------------------------- use Net::FTP; $host = 'ftp.ftpserver.com'; $user = 'anonymous'; $pass = 'someone@somewhere.com'; $remote_dir = '/pub/path/to/files'; $download_filter = "*.myfile.exe"; $destination_dir = "./"; print "Opening FTP connection to $host\n"; my $ftpBox = Net::FTP->new($host) || die "failed to connect to $host $!"; $ftpBox->login($user, $pass) || die "failed to log onto $host $!"; $ftpBox->pasv(); if($remote_dir !~ /^ *$/) { print "Changing remote directory to $remote_dir\n"; $ftpBox->cd($remote_dir) || die "failed to cwd to $remote_dir on $host ftp $!"; } @file_list = $ftpBox->ls($download_filter); foreach $filename (@file_list) { print "getting $filename\n"; $ftpBox->get($filename, $destination_dir . $filename) || die "failed to get $filename to $destination_file"; } print "Closing FTP download connection...\n"; $ftpBox->quit;

In reply to Net::FTP Server does not support cwd...alternatives? by linebacker

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.