I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2012-03-01 16:58:34.552746-08 by normastitz
rput fails (sort of) if target dir exists
Originally posted on stackoverflow.
my ( $user, $password, $host ) = @_; my ( $source, $dest ) = '/whatever'; my $sftp = Net::SFTP::Foreign->new( user => $user, host => $host, password => $password, more => [ -o => 'StrictHostKeyChecking no' ] ); $sftp->rput( $source, $dest, overwrite => 1, on_error => sub { print $sftp->error; } );
If $dest exists on $host, rput's on_error always fires and the error is "Remote directory '/whatever' already exists" Despite the error, rput carries on and recursively copies the dir, but on the taget host it'll get copied under /whatever, instead of over /whatever. i.e. I end up with /whatever/whatever. This serves as a crumby workaround if done before the rput, but I don't actually want to remove the destination dir:
$sftp->rremove( $dest );
Anyone have any idea what I'm doing wrong?
Direct Responses: 13708 | Write a response