masteradit has asked for the wisdom of the Perl Monks concerning the following question:
I built a code for pushing the data from my Windows machine to Unix machine using the SFTP protocol. For the purpose I used NET::SFTP::Foreign. The part of code is mentioned below.
#!c:\Perl\bin\perl use Net::SFTP::Foreign; use Net::SSH2; $user="abcd"; $passwd="abcd@1234"; $host = "192.168.10.2"; $port = "22"; $sftp = Net::SFTP::Foreign->new($host, backend => 'Net_SSH2',username +=> $user, password => $passwd, port => $port) || die $sftp->error; print " SFTP Connected \n"; for ($i = 0; $i <= 23; $i++) { $filename = "testfile".$i.".csv"; $sftp->put("c:\\documents\\$filename", "/usr/home/abcd/$filename"|| pr +int $sftp->error; print $sftp->status; }
Using the above code, I am able to transfer the files but as soon as the it tries to transfer the 4th file it gives me error "write failed: LIBSSH2_ERROR_EAGAIN (-37): Unable to send channel data" and Status as "Connection lost". All the subsequent files while putting generate error "Connection to remote server stalled" with status message "Connection lost". I need to run my script few more times to transfer remaining files.
The OS is Windows 7, Perl version is v5.10.1 and Net::SFTP::Foreign version is 1.62.
Can someone please guide me why connection is getting stalled after transferring few files and what is way out?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Strange behavior for PUT function in Net::SFTP::Foreign
by salva (Canon) on Sep 05, 2011 at 10:55 UTC | |
by masteradit (Initiate) on Sep 05, 2011 at 11:09 UTC | |
by masteradit (Initiate) on Sep 05, 2011 at 11:57 UTC | |
by salva (Canon) on Sep 05, 2011 at 12:02 UTC | |
by salva (Canon) on Sep 05, 2011 at 12:04 UTC | |
|
Re: Strange behavior for PUT function in Net::SFTP::Foreign
by kcott (Archbishop) on Sep 05, 2011 at 11:01 UTC |