Thread Problems with Net::SFTP (1 answers)
Opened by prassito at 2005-05-31 09:47

renee
 2005-05-31 10:20
#29486 #29486
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
ls does not return a hash, but a list of the entries. Each element of the list contains a reference to a hash. I'm not familiar with the CPAN:Net::SFTP-module, but try the following code:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
my %sftp_args = (user =>$ftpuser, password =>$ftppwd);

#Open Connection
$ftp = Net::SFTP->new($ftphost, %sftp_args) || exception("SFTP-Login failed (maybe wrong Username or Password?)");

#List all from the downloadpath
my @entries = $ftp->ls($downloadpath);

#Loop through my result
foreach my $file (@entries){
  next if($file->{filename} =~ /^\.\.?$/);
  $tmp_in_file = $file->{filename};

  $ftp->get($downloadpath."/".$tmp_in_file, $localpath_in."/".$tmp_in_file);
  $ftp->do_remove($downloadpath."/".$tmp_in_file);
}
\n\n

<!--EDIT|renee|1117520462-->
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Problems with Net::SFTP