Hello
I do not manage to copy the files on a remote sftp dir then once the file is copied and only if the copy is successful delete the file.
I have tried with net:sftp::foreign rget and get methods but they always complain that my localdir is a directory
thanks#! /usr/bin/env perl use strict; use warnings; use feature qw(say); use autodie; use Net::SFTP::Foreign; use constant { HOST => "sftp.mariog.net", REMOTE_DIR => "/Daily", LOCAL_DIR => "/root", USER_NAME => "MGO", PASSWORD => "mypass", DEBUG => "0", }; my $sftp; $sftp = Net::SFTP::Foreign->new ( HOST, timeout => 240, user => USER_NAME, password => PASSWORD, autodie => 1, ); # # Fetch Files # $sftp->setcwd( REMOTE_DIR ); my @files = @{ $sftp->ls }; #Returns a reference to an array of hashe +s for my $file ( @files ) { $sftp->get($file->{filename}, LOCAL_DIR) or die "file transfer failed: " . $sftp->error; $sftp->remove( $file->{filename} ); } $sftp->disconnect;
In reply to copy files on sftp to local dir and delete copied file by mariog
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |