ReadDirectory() problem using Perl

I have managed to write a Perl program that makes an FTP connection and uploads several files. When I was done I tried to write a routine that would read the directory and show me the files in it. The problem I seem to be having is that after I issue the ReadDirectory method my {Items} looks like this (using Data::Dump):

bless({
# tied Win32::OLE::Tie
Count => 16,
Item => undef,
}, "Win32::OLE")


Although the count, 16, is correct there are no actual items in {Item}.

I wrote a program that just does the connection and attempts to read the directory, the program, output and log file are below.

As a side note the ReadDirectoryRaw method works perfectly and creates a file with the directory info in it.

Any help would be greatly appreciated!

-Alan

[Post editted to change ReadDirectoryFromCommand() to ReadDirectory(), the results are identical.]

Here is my program:
=============

#///////////////////////////////////////////////////////////////////////////////////
#//
#// Testdir.pl
#//
#///////////////////////////////////////////////////////////////////////////////////

use Win32::OLE;
use Win32::OLE::Variant;
use Data::Dump qw(dump pp ddx);
# ==========================================
# Setup the FTP connection
# ==========================================
$ftp = Win32::OLE->new('sfFTPLib.FTPConnectionMTA');

$ftp->{Host} = "xxx";
$ftp->{Username} = "xxx";
$ftp->{Password} = "xxx";

$ftp->{Port} = 21;
$ftp->{Passive} = 1; # Use Passive mode.
$ftp->{MLST} = 1; # Use the MLSD command to list directories
$ftp->{Protocol} = 2; # FTP over SSL Explict
$ftp->{Logfile} = "log.txt";
$ftp->{LISTOption} = 1;
unlink("log.txt");
# ==========================================
# Make the FTP connection
# ==========================================
print "\nAttempting to connect ...\n";
if ($ftp->Connect() == 0)
{
if ($ftp->ChangeDirectory("test") == 0)
{
print "Change directory worked\n";
}
else
{
die "Change directory failed\n";
}
}
else
{
die "Could not connect.\n";
}
$dir = $ftp->{WorkingDirectory};
print "\nCurrent directory is: $dir \n\n";
print "Reading server directory\n";
if ($ftp->ReadDirectory() == 0)
{
$temp = $ftp->{Items};
print "\nDump:\n" . pp($temp) . "\n\n";
}
$ftp->Close();


Here is the output:
============

H:\Perl\programs>perl testdir.pl

Attempting to connect ...
Change directory worked

Current directory is: /xxx/test

Reading server directory

Dump:
bless({
# tied Win32::OLE::Tie
Count => 16,
Item => undef,
}, "Win32::OLE")



And here is the log file:
================

[20090130 13:37:38] SmartFTP FTP Library v1.5.17.12
[20090130 13:37:38] Resolving host name "xxx"
[20090130 13:37:38] Connecting to xxx Port: 21
[20090130 13:37:38] Connected to xxx
[20090130 13:37:39] 220 xxx FTPS Server
[20090130 13:37:39] AUTH TLS
[20090130 13:37:39] 234 AUTH TLS successful
[20090130 13:37:39] Connected. Exchanging encryption keys...
[20090130 13:37:42] Session Cipher: 128 bit AES
[20090130 13:37:42] TLS encrypted session established.
[20090130 13:37:42] Command channel protection set to Private.
[20090130 13:37:42] PBSZ 0
[20090130 13:37:42] 200 PBSZ 0 successful
[20090130 13:37:42] USER xxx
[20090130 13:37:42] 331 Password required for xxx.
[20090130 13:37:42] PASS xxx
[20090130 13:37:44] 230 User xxx logged in.
[20090130 13:37:44] SYST
[20090130 13:37:44] 215 UNIX Type: L8
[20090130 13:37:44] Detected Server Type: UNIX
[20090130 13:37:44] RTT: 29.795 ms
[20090130 13:37:44] FEAT
[20090130 13:37:44] 211-Features:
[20090130 13:37:44] MDTM
[20090130 13:37:44] REST STREAM
[20090130 13:37:44] SIZE
[20090130 13:37:44] AUTH TLS
[20090130 13:37:44] PBSZ
[20090130 13:37:44] PROT
[20090130 13:37:44] 211 End
[20090130 13:37:44] PWD
[20090130 13:37:45] 257 "/xxx" is current directory.
[20090130 13:37:45] CWD test
[20090130 13:37:45] 250 CWD command successful
[20090130 13:37:45] PWD
[20090130 13:37:45] 257 "/xxx/test" is current directory.
[20090130 13:37:45] TYPE I
[20090130 13:37:45] 200 Type set to I
[20090130 13:37:45] PROT C
[20090130 13:37:45] 200 Protection set to Clear
[20090130 13:37:45] PASV
[20090130 13:37:45] 227 Entering Passive Mode (xxx).
[20090130 13:37:45] Opening data connection to xxx Port: 40000
[20090130 13:37:45] LIST
[20090130 13:37:45] 150 Opening ASCII mode data connection for file list
[20090130 13:37:45] 1072 bytes transferred. (16.8 KB/s) (62 ms)
[20090130 13:37:45] 226 Transfer complete.
[20090130 13:37:45] Client closed the connection.

Poking around in the forums I saw references to registering the correct version of sfFTPlib.dll, I decided to see what I have installed. Below is what I found, not sure which version is currently registered or how to find out.


C:\>dir sfftplib.dll /s /p
Volume in drive C has no label.
Volume Serial Number is 8AAF-EA82

Directory of C:\Program Files\Beyond Compare 2

08/24/2006 04:37 PM 2,633,392 sfFTPLib.dll
1 File(s) 2,633,392 bytes

Directory of C:\Program Files\SmartFTP Client

11/23/2008 04:50 PM 2,898,216 sfFTPLib.dll
1 File(s) 2,898,216 bytes

Directory of C:\Program Files\SmartFTP FTP Library

01/09/2009 05:14 PM 2,837,256 sfFTPLib.dll
1 File(s) 2,837,256 bytes

Directory of C:\Program Files\SmartFTP FTP Library\x64

01/09/2009 04:30 PM 3,650,344 sfFTPLib.dll
1 File(s) 3,650,344 bytes

I got a program that tells me currently registered DLLs, it looks like the currently registered version is this one:

Directory of C:\Program Files\SmartFTP FTP Library

01/09/2009 05:14 PM 2,837,256 sfFTPLib.dll


Which seems to be correct, it is version 1.5.17.12

You have the correct dll registered. I'm not sure why Perl thinks that the collection is empty. We use the standard way to expose the Items collection. Are the VbScript examples (Samples\FTP\Script) working for you for example?

I will try to do some research what Perl expects and why it doesn't work as it should.

Regards,
Mat

I haven't tried the VB Script samples, I can do that on Monday. It could be my Perl version too, I will check that on Monday also.