in reply to Net::FTPSSL->get() issue

For starters, very few servers will allow you to delete; hence, "delete" $ftps->delete($file). Also, if the timestamp is being mangled, that's because, by default, Net::FTPSSL doesn't preserve timestamps. You'll need to add PreserveTimestamp to the new method. Here's what I tried:
#!/usr/bin/perl use strict; use warnings; use Net::FTPSSL; use constant HOST => 'ftp.perl.org'; use constant DIR => '/pub/CPAN'; use constant REMOTE_FILE => 'README'; use constant LOCAL_FILE => 'README'; my $ftps = Net::FTPSSL->new(HOST, PreserveTimestamp => 1, Port => 21, Debug => 1, Croak => 1, Trace => 1); $ftps->login('user', 'pass'); $ftps->cwd(DIR); if ( $ftps->get(REMOTE_FILE, LOCAL_FILE) ) { open(MYLOG, '>', 'Mylog.txt'); print MYLOG time() . " LOCAL_FILE was downloaded from HOST\n"; } else { print "There was a problem.\n"; } unlink(LOCAL_FILE); $ftps->quit();
Update: Here's an example using Tie::Scalar::Timestamp
#!/usr/bin/perl use strict; use warnings; use Net::FTPSSL; use constant HOST => 'ftp.perl.org'; use constant DIR => '/pub/CPAN'; use constant REMOTE_FILE => 'README'; use constant LOCAL_FILE => 'README'; my $ftps = Net::FTPSSL->new(HOST, PreserveTimestamp => 1, Port => 21, Debug => 1, Croak => 1, Trace => 1); $ftps->login('anonymous'); $ftps->cwd(DIR); if ( $ftps->get(REMOTE_FILE, LOCAL_FILE) ) { use Tie::Scalar::Timestamp; $Tie::Scalar::Timestamp::DEFAULT_STRFTIME = '%H:%M:%S'; open(MYLOG, '>', 'Mylog.txt'); tie my $timestamp, 'Tie::Scalar::Timestamp'; print MYLOG $timestamp . " LOCAL_FILE was downloaded from HOST\n"; } else { print "There was a problem.\n"; } unlink(LOCAL_FILE);

Replies are listed 'Best First'.
Re^2: Net::FTPSSL->get() issue
by zow (Sexton) on Feb 06, 2010 at 17:37 UTC

    Thanks, I will give that a shot Monday. Trying to set up a FTPS server at home to be able to play with this sort of thing off hours...

    zow