Difference between revisions of "Unison.pl"

From Organic Design
Jump to: navigation, search
m
m (cat in)
Line 16: Line 16:
 
}
 
}
 
</perl>
 
</perl>
[[Category:PERL]]
+
[[Category:PERL]][[Category:Backup]]

Revision as of 00:29, 19 July 2009

<perl>

  1. !/usr/bin/perl

use Expect; require( '/var/www/tools/wikid.conf' ); $bak_user = $name unless defined $bak_user;

for $dir ( @bak_paths ) { $cmd = "unison $dir ssh://$bak_user\@$bak_server$dir -batch -force $dir"; $exp = Expect->spawn( $cmd ); $exp->expect( undef, [ qr/password:/ => sub { my $exp = shift; $exp->send( "$bak_pass\n" ); exp_continue; } ], [ qr/Synchronization complete/ => sub { } ], ); $exp->soft_close(); } </perl>