Hi All,

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?


In reply to Strange behavior for PUT function in Net::SFTP::Foreign by masteradit

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.