jonp has asked for the wisdom of the Perl Monks concerning the following question:

Hey monks,
I am new at using Net::SFTP, I am just trying to get the basics down. I have varified that I can connect to this host and port number using a windows sftp client called "WinSCP3". I really can't figure out why I get this error when I try to connect to the host computer:

Can't set socket non-blocking: Bad file descriptor at C:/Perl/site/lib/Net/SSH/Perl.pm line 213, <GEN0> line 1.

here is my code:
use Net::SFTP; my $host = "cib-xcluster.biotec.usu.edu"; my %args = ( user => 'user', password => 'pass', debug => 0, protocol => '1,2', port => '22', ); print "connecting to $host . . .\n"; my $sftp = Net::SFTP->new($host, %args); print "Finished\n";

Any help would be really appreciated.
jonp

Replies are listed 'Best First'.
Re: Net::SFTP error
by idsfa (Vicar) on Oct 07, 2005 at 18:09 UTC
    1. use warnings; use strict;
    2. debug => 1
    3. protocol and port are not valid args, read the docs

    You might do well to read through the example that ships with the module. (snippet follows)

    my %args = (ssh_args => []); $args{debug} = 1 if $opts{v}; push @{ $args{ssh_args} }, compression => 1 if $opts{C}; print "Connecting to $host...\n"; my $sftp = Net::SFTP->new($host, %args);

    The intelligent reader will judge for himself. Without examining the facts fully and fairly, there is no way of knowing whether vox populi is really vox dei, or merely vox asinorum. -- Cyrus H. Gordon
Re: Net::SFTP error
by pboin (Deacon) on Oct 06, 2005 at 21:15 UTC

    Your error message means what it says: Bad file descriptor <GEN0>. That's not part of the code you posted, but I'm not sure if it's coming from your code or from a module.

    Did you run the posted snippet and get that error?

    Oh, and use strict;.