Topic "SFTP connection with perl"

Author Message
[View user's profile]

Joined: 2014-05-16
Posts: 2
Location: Germany
I want connect with a perl script. I must use an proxy server. There ist no example for proxy and i have no idea.
Thank you for your answer.

My script for testing:


use strict;
use Win32::OLE;
use Win32::OLE::Const;
use Win32::OLE::Variant;
use feature qw(switch); # in order to use given

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

sub session_Events()
    my ($obj, $event, @args) = @_;
    given ($event)
        when ('FileTransferred')
            my ($sender, $e) = @args;
            printf "%s => %s\n", ( $e->{'FileName'}, $e->{'Destination'} );
my $session = Win32::OLE->new('WinSCP.Session');
my $consts = Win32::OLE::Const->Load($session);
my $sessionOptions = Win32::OLE->new('WinSCP.SessionOptions');
$sessionOptions->{'Protocol'} = $consts->{'Protocol_Sftp'};
$sessionOptions->{'HostName'} = '';
$sessionOptions->{'UserName'} = 'user';
$sessionOptions->{'Password'} = 'passwort';

$session->Open( $sessionOptions);
# Upload files
my $transferOptions = Win32::OLE->new('WinSCP.TransferOptions');
$transferOptions->{'TransferMode'} = $consts->{'TransferMode_Binary'};
my $transferResult = $session->PutFiles('c:\\temp\\test.*', '/usr', FALSE, $transferOptions);

# Throw on any error
# Print results
my $items = Win32::OLE::Enum->new($transferResult->{'Transfers'});
my $item;
while (defined($item = $items->Next))
    print $item->{'FileName'} . "\n";
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26331
Location: Prague, Czechia
Please read documentation:
Martin Prikryl
[View user's profile]

Joined: 2014-05-16
Posts: 2
Location: Germany
Solution for perl:


$sessionOptions->AddRawSettings('ProxyHost', '?.?.?.?');
$sessionOptions->AddRawSettings('ProxyPort', '80');
$sessionOptions->AddRawSettings('ProxyUsername', '<usr>');
$sessionOptions->AddRawSettings('ProxyPassword', '<pw>');

You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License