> ramon via lepton wrote:
> Has anyone been successful in using rsync with perl?
> Thanks,
> ramon
Ramon,
If your just looking for a small example, here is part of an
web api that I wrote for end users to sync content between
web servers :
$command = "/usr/local/bin/rsync" .
" $excludes $includes $all_patterns" .
" -n -v $args -e /usr/local/bin/ssh --delete" .
" $local_path " .
" $dest_server:$remote_path " ;
# The delete output is sent to STDERR
open(SYNC, "$command 2>&1|");
# Only try to count files that are valid to transfer.
while(<SYNC>) {
next if ($_ =~ /^skipping directory /);
next if ($_ =~ /^building file list/);
next if ($_ =~ /^wrote.*bytes/);
next if ($_ =~ /^total size is /);
# Count pushes and deletes separately
# Highlight the delete lines in red font.
if ($_ =~ /^deleting /) {
$delete_count += 1;
$_ =~ s|^deleting |<font color=red>deleting </font> |;
} else {
$push_count += 1;
}
print $_, "<br>\n";
}
close(SYNC);
- Zoli