Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found