How can I use Perl's Net::SFTP::Foreign on Windows?

I think the constructor is expecting a hashtable and not a reference to a hash. Try removing the braces in your call.

Up vote 1 down vote favorite share g+ share fb share tw.

I installed Net::SFTP::Foreign in my perl 5.8.8 and I'm trying to log in to a Secure FTP server using the below code: use Net::SFTP::Foreign; my $host = $tt->get_ftp_server_address(); my $sftp = Net::SFTP::Foreign->new("$host", {user=>$tt->get_location_user_name(), password=>$tt->get_location_user_password(), port=>'22'}); The line where I try to call Net::SFTP::Foreign->new fails without throwing any error on me. Perl sftp link|improve this question edited Feb 25 '10 at 22:07brian d foy53.3k1667219 asked Feb 25 '10 at 15:26goe463619 61% accept rate.

– toolic Feb 25 '10 at 15:35 1 I have two debugging statments in the code that print to the log. One is before the ->new and the other comes after it. The first one prints to the log the second doesn't.

So perl fails on the Net::SFTP::Foreign->new call. – goe Feb 25 '10 at 15:37 Use the perl debugger and step through the Net::SFTP::Foreign package code. – mob Feb 25 '10 at 16:15 1 @geo It looks like you are in the habit of quoting variables even when it is patently unnecessary.

See perldoc.perl.org/… – Sinan Ünür Feb 25 '10 at 19:33 1 @goe: how do you know the second debugging statement isn't the failure? Seriosuly, show us the complete working example that demonstrates the behavior so we can see what you are doing. – brian d foy Feb 25 '10 at 22:06.

I think the constructor is expecting a hashtable and not a reference to a hash. Try removing the braces in your call: my $sftp = Net::SFTP::Foreign->new("$host", user=>$tt->get_location_user_name(), password=>$tt->get_location_user_password(), port=>'22').

Note Net::SFTP::Foreign does not requiere (sic) a bunch of additional modules and external libraries to work, just the OpenBSD SSH client (or any other client compatible enough). – Sinan Ünür Feb 25 '10 at 19:29.

" here. The readme states you need to have an external SSH2 client reachable from your PATH. Could that be the problem?

The module is known to work on windows.

– goe Feb 25 '10 at 16:03 In the constructor, you can specify in the %args your ssh client with 'ssh_cmd' key - not sure if you can use WinSCP from the command line – ccheneson Feb 25 '10 at 16:28.

You can also set the 'debug' to 1 in the %args to the constructor From the Net::SFTP::Foreign doc: debug => 1 if set to a true value, debugging messages will be printed out. The default is false. Edit: Try $Net::SFTP::Foreign::debug = 1; From the source of the 1.56_04 version: we make $Net::SFTP::Foreign::Helpers::debug an alias for $Net::SFTP::Foreign::debug so that the user can set it without knowing anything about the Helpers package!

Our $debug.

There's no debug => 1 in that doc – goe Feb 25 '10 at 16:48 Oops my bad,was looking at a older version of the module. – ccheneson Feb 25 '10 at 16:58.

Password authentication is not supported on Windows unless you use Cygwin Perl. You will have to install Expect also. Development versions (currently, 1.56_08) can be used with Net::SSH2, so you get a rich SFTP client and password authentication.

Net::SFTP::Foreign can also work with plink (a utility that comes with Putty), that combination supports password authentication under Windows but it is not completely secure.

In addition to the possibility of turning on debugging, note that the documentation clearly states: An explicit check for errors should be included always after the constructor call: my $sftp = Net::SFTP::Foreign->new(...); $sftp->error and die "SSH connection failed: " . $sftp->error; So, printing out that error message would be the first step in diagnosing issues.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions