Net-OpenSSH

 view release on metacpan or  search on metacpan

examples/keep_in_sync.pl  view on Meta::CPAN

# See: http://stackoverflow.com/q/6781104/124951


use Net::OpenSSH;
use Linux::Inotify2;
use Time::HiRes qw(sleep);

my $usage = "Usage:\n  $0 local_dir [user\@]host remote_dir\n\n";

@ARGV == 3 or die $usage;
my ($local, $host, $remote) = @ARGV;

-d $local or die $usage;

my $ssh = Net::OpenSSH->new($host);
$ssh->error and die "unable to connect to remote host: " . $ssh->error;

my $inotify = Linux::Inotify2->new;
$inotify->watch ($local, IN_MODIFY|IN_MOVED_TO);

$ssh->rsync_put({verbose => 1, glob => 1}, "$local/*", $remote);



( run in 0.437 second using v1.01-cache-2.11-cpan-49f99fa48dc )