Differences

This shows you the differences between the selected revisions of the page.

2012-03-05 2012-03-05
Sorry missing letter in comment (brablc) Change creation of TransferOptions, replace quotes (brablc)
Line 88: Line 88:
use strict; use strict;
use warnings; use warnings;
-use feature qw(switch); 
use Win32::OLE; use Win32::OLE;
Line 99: Line 98:
    FALSE => Variant(VT_BOOL, 0)     FALSE => Variant(VT_BOOL, 0)
}; };
- 
-# Required for WithEvents to stop complaining 
-Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE); 
my $session = Win32::OLE->new('WinSCP.Session'); my $session = Win32::OLE->new('WinSCP.Session');
-Win32::OLE->WithEvents($session, \&session_Events); 
# Load constants # Load constants
Line 113: Line 108:
$sessionOptions->{'Protocol'} = $consts->{'Protocol_Sftp'}; $sessionOptions->{'Protocol'} = $consts->{'Protocol_Sftp'};
-$sessionOptions->{'HostName'} = "example.com"+$sessionOptions->{'HostName'} = 'example.com'
-$sessionOptions->{'UserName'} = "user"+$sessionOptions->{'UserName'} = 'user'
-$sessionOptions->{'Password'} = "mypassword"+$sessionOptions->{'Password'} = 'mypassword'
-$sessionOptions->{'SshHostKey'} = "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx";+$sessionOptions->{'SshHostKey'} = 'ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx';
# Connect # Connect
Line 122: Line 117:
# Upload files # Upload files
-my $transferOptions = WScript.CreateObject("WinSCP.TransferOptions");+my $transferOptions = Win32::OLE->new('WinSCP.TransferOptions');
$transferOptions->{'TransferMode'} = $consts->{'TransferMode_Binary'}; $transferOptions->{'TransferMode'} = $consts->{'TransferMode_Binary'};
-my $transferResult = $session->PutFiles("d:\\toupload\\*", "/home/user/", FALSE, $transferOptions);+my $transferResult = $session->PutFiles('d:\\toupload\\*', '/home/user/', FALSE, $transferOptions);
# Throw on any error # Throw on any error
-$transferResult.Check();+$transferResult->Check();
# Print results # Print results

Last modified: by brablc