Perl, ListDirectory, Can't see files

Advertisement

Tharg
Donor
Joined:
Posts:
2

Perl, ListDirectory, Can't see files

Hi -

My WWinscp is V 5.5.3 (in the client).

I have been trying to use it with Perl and ftps.

I don't have direct access to the server (for logs etc).

My perl script, so far (based on an example), is :

use strict;
use warnings;
 
use Win32::OLE;
use Win32::OLE::Const;
use Win32::OLE::Variant;
 
use Data::Dumper;

use constant
{
    TRUE  => Variant(VT_BOOL, 1),
    FALSE => Variant(VT_BOOL, 0)
};

my $Host   = 'REDACTED';
my $User   = 'REDACTED';
my $Password   = 'REDACTED';


my $session = Win32::OLE->new('WinSCP.Session');
 
# Load constants
my $consts = Win32::OLE::Const->Load($session);
 
# Setup session options
my $sessionOptions = Win32::OLE->new('WinSCP.SessionOptions');
 
$sessionOptions->{'Protocol'} = $consts->{'Protocol_Ftp'};
$sessionOptions->{'FtpSecure'} = $consts->{'FtpSecure_ExplicitSsl'};
$sessionOptions->{'FtpMode'} = $consts->{'FtpMode_Passive'};
$sessionOptions->{'HostName'} = $Host;
$sessionOptions->{'UserName'} = $User;
$sessionOptions->{'Password'} = $Password;
$sessionOptions->{'TransferMode'} = $consts->{'TransferMode_Binary'};
 
# Connect
$session->Open($sessionOptions);

my $Files = $session->ListDirectory("/20140506")->Files();

while ( defined( my $File = $Files->Next ) ){
   printf STDOUT ("%s\n", "..." );
   printf STDOUT ("%s\n", $File->Name );
   printf STDOUT ("%s\n", $File->Name() );
   printf STDOUT ("%s\n", $File->Length() );
}

And I never find any files. If I try to transfer a file on to the server instead, this works fine.

I'm afraid that although I'm reasonably good with Perl, I'm not in any way confident with using it in this way, with Win32::OLE etc. I don't know how to check for errors here or whatever.

I can connect using the WinSCP client and see file lists etc.

Thanks for any help!

Reply with quote

Advertisement

Tharg
Donor
Joined:
Posts:
2

Thank you so much, this has now worked.

I have struggled with getting perl's NET::FTPSSL working for some time, and finally found that the server I'm connecting to requires re-use of the data connection, which that library does not support.

Now it looks like, with WinSCP, I will be able to get everything working as I need it to. I made a donation - have a drink or a pizza on me.

Reply with quote

Advertisement

You can post new topics in this forum