Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Unable to connect to some SFTP servers using Perl::SFTP

by skylinedreamer (Novice)
on Apr 08, 2013 at 10:26 UTC ( #1027462=perlquestion: print w/replies, xml ) Need Help??
skylinedreamer has asked for the wisdom of the Perl Monks concerning the following question:

Hi PerlMonks,

I am trying to batch process sftp file transfers using perl threads. I am passing the login information to the method while i start the thread. I am using a Solaris SPARC Machine

My code is as follows with the error msg below. I am also getting a Bus error (core dumped) error.

Seeking your advice on the same. Thanks

sub sub1 { my @InboundParameters = @_; my $num = $InboundParameters[0]; print "started thread $num : Establishing connection with $Inbound +Parameters[1]\n"; my $host = $InboundParameters[2]; my $sftp = Net::SFTP->new($host, user => $InboundParameters[3], password => $InboundParameters[4], debug => 0) or (print "Unable to connect to $Inbou +ndParameters[1]\n", return $num); print "Connected with $InboundParameters[1]\n"; print "done with thread $num\n"; return $num; }
Error Msgs :-
thread failed to start: Permission denied at /xxxxx/5.8.8/Net/ +line 62 Bus error (core dumped)
thread failed to start: Can't connect to, port 22: Conn +ection refused at /xxxx/5.8.8/Net/SSH/ line 208.

Replies are listed 'Best First'.
Re: Unable to connect to some SFTP servers using Perl::SFTP
by hdb (Monsignor) on Apr 08, 2013 at 10:43 UTC

    What springs to attention is your use of $InboundParameters[1] and $InboundParameters[2]. The former is used in the information printed while the latter contains host information. Any chance they are inconsistent when you call your sub?

      The $InboundParameters[1] is the name of the host and $InboundParameters[2] is the address of the host.

      I am only able to connect with one of the host in my list using the script.

      But when I use the terminal to connect all of them are able to connect. It's only whne I use the perl library, its not able to connect.

Re: Unable to connect to some SFTP servers using Perl::SFTP
by salva (Abbot) on Apr 09, 2013 at 08:13 UTC
    The bus error indicates that probably Net::SFTP, Net::SSH::Perl or some of their dependencies are not thread safe. The only way to solve that kind of problem reliably is, unfortunately, to find the broken module and to fix it.
      hm.. i dont have access to repair the modules. I guess i have to look into other options in tht case then :-)
        If you only need to run your script on Linux/Unix systems, then, consider using processes (via fork) instead of threads.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1027462]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2018-02-18 06:01 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (250 votes). Check out past polls.