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

prassito
 2005-05-31 09:47
#29485 #29485
User since
2005-05-31
8 Artikel
BenutzerIn
[default_avatar]
Hi Folks

While working with the Net::SFTP Module of Perl i realized a problem i can't solve.
I have a directory with the following files, i want to download from the remote PC to my local server (at least the xml-Files) with a Perl-Skript using SFTP:

drwxr-xr-x    2 uh       uh           4096   31. Mai 07:38 .
drwxr-xr-x    8 uh       uh           4096   30. Mai 16:21 ..
-rw-r--r--    1 root     root            103   31. Mai 07:38 file_a.xml
-rw-r--r--    1 root     root            230   31. Mai 07:38 file_b.xml
-rw-r--r--    1 root     root           1432  31. Mai 07:37 file_c.xml
-rw-r--r--    1 root     root            674   31. Mai 07:37 file_d.xml


I am able to open the connection and put some files onto the remote server.
But if is try to get my four files i can only see the '.', '..' and randomly one of the XMLs.
Anyone got an idea what's wrong?
Thanks and gratz

prassito


<----zip------->
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Initialisation
my %hashval;
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
%hashval = $ftp->ls($downloadpath);

#Loop through my result
foreach my $_file (%hashval)
{
   $tmp_in_file = $hashval{$_file}->{"filename"};

#We Skip . and ..
   if ($tmp_in_file eq ".." || $tmp_in_file eq ".")
   {
       next();
   }
   else
  {
       $ftp->get($downloadpath."/".$tmp_in_file, $localpath_in."/".$tmp_in_file);
       $ftp->do_remove($downloadpath."/".$tmp_in_file);
   }
}


edit pq: code-tags hinzugefügt\n\n

<!--EDIT|pq|1117537270-->

View full thread Problems with Net::SFTP