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?
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |