Hey guys,
How I will come to know my perl script for copying files (generally very big sized file 1000 gb ) between two server successed or interupted ? How I will get the error status of the scp commmand I used for copying file ?
Thanks in advance
Hey guys,
How I will come to know my perl script for copying files (generally very big sized file 1000 gb ) between two server successed or interupted ? How I will get the error status of the scp commmand I used for copying file ?
Thanks in advance
For : transferring very large files reliably means two things — detect the transfer program’s exit status, and independently verify the result (size or checksum). and pointed toward alternate tools and CPAN helpers; below is a concise, practical checklist and ready-to-run Perl patterns you can drop into a script.
The simplest check is Perl’s system() plus the special variable $?. It tells whether the command failed to exec, died by signal, or returned a nonzero exit code:
my $cmd = "rsync -av --partial /src user\@host:/dest";
system($cmd);
if ($? == -1) {
die "failed to execute: $!";
} elsif ($? & 127) {
die sprintf("child died with signal %d%s\n", $? & 127, ($? & 128) ? " (core dumped)" : "");
} else {
my $exit = $? >> 8;
die "transfer failed (exit $exit)\n" if $exit != 0;
print "transfer exit=0 OK\n";
} For more visibility capture stdout/stderr (IPC::Open3 or IPC::Run3) so logs contain why a transfer failed. Then do an independent integrity check: compare file sizes with -s or compute a streaming checksum with Digest::SHA on both ends (you can fetch the remote checksum via an SSH command). Example sketch:
use Digest::SHA;
# compute local sha256
open my $fh, '<', $local or die $!;
binmode $fh;
my $sha = Digest::SHA->new(256);
$sha->addfile($fh);
my $local_hex = $sha->hexdigest;
# get remote hex via ssh and compare Practical tips: test the whole flow on a small file first; for multi-GB/TB transfers check remote disk space, run transfers under screen/nohup, enable resume/partial options, log everything, and implement retries with exponential backoff. Be aware that full checksums on huge files are I/O-heavy; size+mtime can detect most problems faster, checksum for final verification.
Jump to Post— mitchems 12What protocol are you using to copy the files? I like which can be used to copy a file via HTTP.
What protocol are you using to copy the files? I like which can be used to copy a file via HTTP.
I am trying to use rsync tool of linux ???? I am trying to develop a script by using this script ??? any help ...
Thanks Kevin! I was gonna post the same thing!
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.