Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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/SFTP.pm +line 62 Bus error (core dumped)
thread failed to start: Can't connect to xxx.xx.xxx.xxx, port 22: Conn +ection refused at /xxxx/5.8.8/Net/SSH/Perl.pm line 208.

Comment on Unable to connect to some SFTP servers using Perl::SFTP
Select or Download Code
Re: Unable to connect to some SFTP servers using Perl::SFTP
by hdb (Prior) 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 (Monsignor) 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1027462]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2014-10-21 19:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (106 votes), past polls