Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

Ajay

Re: Can't create winscp sessoion: Win32::OLE(0.1712) error 0x800401f3: "Invalid class string"

Thanks Martin. That indeed was the cause of the failure. Registered the library and All sorted now.
martin

Re: Can't create winscp sessoion: Win32::OLE(0.1712) error 0x800401f3: "Invalid class string"

Ajay wrote:

Hi, When using the sample code for WinSCP using Perl, i get an error

my $session = Win32::OLE->new('WinSCP.Session') || die "Can't create winscp sessoion: ", Win32::OLE->LastError;

Can't create winscp sessoion: Win32::OLE(0.1712) error 0x800401f3: "Invalid class string"

Did you register the WinSCP .NET assembly for COM (and for correct architecture)?
https://winscp.net/eng/docs/library_install
Ajay

Can't create winscp sessoion: Win32::OLE(0.1712) error 0x800401f3: "Invalid class string"

Hi, When using the sample code for WinSCP using Perl, i get an error

my $session = Win32::OLE->new('WinSCP.Session') || die "Can't create winscp sessoion: ", Win32::OLE->LastError;

Can't create winscp sessoion: Win32::OLE(0.1712) error 0x800401f3: "Invalid class string"
sonax

example

Solution for perl:

$sessionOptions->AddRawSettings('ProxyMethod','3');

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

SFTP connection with perl

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
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);

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'} = 'test.de';
$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
$transferResult->Check();
 
# Print results
my $items = Win32::OLE::Enum->new($transferResult->{'Transfers'});
my $item;
while (defined($item = $items->Next))
{
    print $item->{'FileName'} . "\n";
}