I'm using perl 5.8.8. I don't have any clue about whether Net::SFTP is thread safe or not.
But I used Net::SFTP::Foreign instead of Net::SFTP and it started working :). Now I'm facing some different problem :(. If I try calling Net::SFTP::Foreign->ls method in any thread function it won't work. Following is the snipet: use threads; use Net::SFTP::Foreign; $Net::SFTP::Foreign::debug = 1; $remDir = '/var/opt/stcroamcommon/data/ready'; my $thread = threads->new (\&ftpThreadEntry,$host,$user,$password,$cnt); sub ftpThreadEntry() { my $host_l = shift; my $usr = shift; my $passwd = shift; my $id = shift; my $prot = 1; my $sftp = undef; print ("In ftpThreadEntry func thr id $id\n"); my %args = ( "user", $usr, "password", $passwd, "more", '-v', "port", 6789 ); $sftp = Net::SFTP::Foreign->new($host_l,%args); my $err = $sftp->error(); # I get 'Password not requested as expected: -1' msg my $stat = $sftp->status(); # $stat = 'No connection' if ($sftp) { my $files_r=$sftp->ls($remDir); # Here I get nothing in $files_r :( my $filename; foreach my $file_r (@$files_r) { $filename=$file_r->{filename}; if($filename ne "." && $filename ne "..") { $filename=$remoteDir."/".$filename; print("File name is $filename\n"); if($sftp->get($filename,$filename)) { print("Returned something \n"); } else { print("=== not returned anything\n"); } } } } $thread->join(); Do anyone have any guess? Thanks for replies. ~~~~~~~~~~~~~~~~~~~~ Thanks and Best regards, ~ Rajnikant Software Engg. Persistent Sys. Ltd. Ph. +91 98222 04088 -----Original Message----- From: Paul Johnson [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 28, 2008 6:02 PM To: Rajnikant Cc: beginners@perl.org Subject: Re: about SFTP and Thread dependency On Wed, May 28, 2008 at 01:33:59PM +0530, Rajnikant wrote: > I was trying to use SFTP in multithreaded application. I observed many > segmentation faults there. > Following is the code snipet: > > use threads; > use Net::SFTP; Is Net::SFTP thread safe? Are you using a recent version of Perl? > This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. Eek! -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/