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