Return to Snippet

Revision: 32125
at September 18, 2010 23:29 by gpupo


Initial Code
#!/usr/bin/perl -w
# @autor gpupo <[email protected]>
# Use on project deployment with ssh keys prompt
# Requeriment: (test on debian) libfile-slurp-perl libfile-read-perl libexpect-perl 
# You need to create a file called .myK containing the password of your key in your home directory. Not the example of safety, sorry:)
use Expect;
use File::Read;
$path = $ENV{"HOME"} ."/.myK"; 
$file = read_file($path);
$prompt = ".ssh/id_rsa':";
$exclude =  $ENV{"HOME"}  . '/wProjects/config/rsync_Cpanel_exclude.txt';
$cmd = 'rsync  -r -t -v -L -z  --progress --stats  --exclude-from='  . $exclude . " @ARGV";
print "\n===== Executing:\n$cmd\n";
$exp = new Expect();
$exp->raw_pty(1);  
$exp->spawn($cmd);
$exp->expect(10000, [ $prompt => sub { $_[0]->send("$file\n"); } ]);
print "\n";
$exp->soft_close();

Initial URL


Initial Description


Initial Title
Automated Deploy (RSYNC)  with key password prompt

Initial Tags


Initial Language
Perl