403Webshell
Server IP : 104.21.13.164  /  Your IP : 216.73.216.44
Web Server : Apache
System : Linux gator4057.hostgator.com 5.14.0-687.17.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jun 22 07:21:26 EDT 2026 x86_64
User : badawi ( 1130)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/perl-Net-OpenSSH/examples/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/doc/perl-Net-OpenSSH/examples/keep_in_sync.pl
#!/usr/bin/perl

use strict;
use warnings;

# This script monitorizes a directory using inotify and when some
# change is detected, uses rsync to update a remote copy.
#
# 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);

while (1) {
    my @events = $inotify->read or die "read error: $!";
    my %changed;
    $changed{"$local/$_->{name}"} = 1 for @events;
    $ssh->rsync_put({verbose => 1}, keys %changed, $remote);
    sleep 0.1;
}

Youez - 2016 - github.com/yon3zu
LinuXploit