3
votes

I’m trying to use WinSCP for SFTP with a Perl script. I’m pretty much using the code off of the WinSCP site verbatim. But I’m getting the following error:

Win32::OLE::CONST->Load: No or invalid type library name at test.pl line 12. Win32::OLE(0.1712): GetOleTypeLibObject() Not a Win32::OLE::TypeLib object at C:/Perl/lib/Win32/OLE/Const.pm line 49.

Does anyone know what could be causing this?

My code:

use Win32::OLE;
use Win32::OLE::Const;
use Win32::OLE::Variant;
 
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE);
my $session = Win32::OLE->new('WinSCP.Session');
 
my $consts = Win32::OLE::Const->Load($session);
 
my $sessionOptions = Win32::OLE->new('WinSCP.SessionOptions');
1
Why are you using WinSCP instead of Perl SFTP modules like Net::SFTP::ForeignAndrey
I feel like this should be a comment. But short answer is I’m experimenting with multiple technologies including Net::SFTP::Foreign.Cory Kleiser

1 Answers

4
votes

Make sure you have registered WinSCP .NET assembly for COM:

%WINDIR%\Microsoft.NET\Framework\<version>\RegAsm.exe WinSCPnet.dll /codebase /tlb