I'm semi-new to Perl, I haven't used it in years. I'm trying to write a basic script to transfer large amounts of data from a windows 7 machine to a linux server. Below is a brief portion of my code (some bits removed but I don't believe they are related to my issues). After much searching, I decided to go with SFTP->FOREIGN with the BACKEND into SSH2. Large in part, everything works great. All of my testing worked liked a charm. However, these tests used small amounts of data (~50MB). My script is set to run nightly at midnight and transfer any new folders on windows to linux. Each folder could be up to 20GB or more. Right now, there are 6 or 7 folders waiting to transfer. I've run it several times and most of the files are transferred, but never all. It'll go through the first folder and copy ~70% - different each time and crash before it has a chance to get the next folder. I can't get any error codes or debug information. No matter what I try, a new cmd windows pops up with an error and it crashes and closes automatically before I can even see it. Getting very frustrating. It looks like I may have to write my own recursion and use the regular 'put' instead of 'rput'. Any ideas?

#!\c:\perl use Net::SSH2; use Net::SFTP::Foreign; use Net::SFTP::Recursive; use File::Copy::Recursive qw (dircopy); use File::Find; use File::Path; use Cwd; use strict; use warnings; if (opendir(DIR, $SOURCE2)){ while (defined ($file = readdir(DIR))) { if (($file eq ".") || ($file eq "..")){ } elsif (-d "$SOURCE2/$file"){ if (-e "$SOURCE2/$file/Transferred to $HOST.txt"){ if (int(-M "$SOURCE2/$file/Transferred to $HOS +T.txt") > $life) { rmtree ("$SOURCE2/$file"); } } elsif (-e "$SOURCE2/$file/RTAComplete.txt") { if (($sftp->rput("$SOURCE2/$file", "$PATH/$fil +e", late_set_perm => 1, overwrite => 0) or die "Rput died: ".$sftp->e +rror) > 0){ open FH, ">$SOURCE2/$file/Transferred to $ +HOST.txt"; print FH ""; close FH; } } } } closedir(DIR); }

In reply to SFTP->RPUT Crashes by joshpc99

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.