I'm using the Net::FTP::File
module to get a list of directories in a remote path. It seemed to work fine until I stepped on this case where a directory named en
shows up as just n
, details:
'n' => {
'Bytes' => '4096',
'Group' => 'client3',
'Owner' => '5004',
'Path' => 'n',
'Last Modified Year/Time' => '17:59',
'Permissions' => 'drwxrwxr-x',
'Last Modified Day' => '17',
'Link To' => undef,
'Number of Links' =>开发者_运维技巧 '7',
'Last Modified Month' => 'Jan'
},
the directory on the server has the correct name (en
) same owner/group/permissions as other directories that display fine.
I reduced the test case to the minimum so I know the problem doesn't depend on other bugs:
#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP::File;
use Data::Dumper;
$Data::Dumper::Terse = 1;
$Data::Dumper::Indent = 1;
my $ftp = new Net::FTP($site);
$ftp->login($user, $pass);
print Dumper $ftp->dir_hashref;
is there anything I'm doing wrong that might cause this error? Or is it a bug in the dir_hashref() function of the module?
Alternatively, what's another (convenient) way to get only the directories in an FTP list? Standard Net::FTP
provides the dir()
method, but it's just a list of ls -l
like strings that have to be parsed.
I'd be inclined to suspect the filename contains an unusual character.
Do you see the file with the correct name if you use a normal FTP client to connect to that server?
Try passing the Debug parameter to the Net::FTP constructor, for instance:
my $ftp = Net::FTP->new($hostname, Debug => 1);
That should get you some more debug info, in particular the dialog between your script and the server, which will likely be of use.
精彩评论