#!/usr/bin/perl use warnings; use strict; use IPC::Open3; $| = 1; my $srcdir = '/home/zentara/testdir_in'; my $dstdir = '/home/zentara/testdir_out'; my $cmd = "rsync -r -v $srcdir $dstdir"; #my $cmd = "rsync -r -v --bwlimit=10 $srcdir $dstdir"; #my $cmd = "rsync -r --dry-run --progress $srcdir $dstdir"; my $pid = open3( \*IN, \*OUT, 0, '/bin/sh' ); ############################################################# #get a count of the files rysnc will transfer for progressbar my $count = 0; my $counter = 0; my $percent = 0; my $last; my $pid1 = open( DR, " $cmd --dry-run |" ) or warn "$!\n"; while () { $last = $_; print; $count++ } close DR; my ($totsize) = $last =~ /^total size is (\d+)/; print "$count\t$totsize\n";