utilisation de Net::SSH1
parent
59cf727e28
commit
51d21ed6c0
|
@ -3,7 +3,7 @@ use Data::Dump "dump";
|
|||
use DNS::ZoneParse;
|
||||
use File::Copy;
|
||||
use Net::SCP;
|
||||
use Net::SSH2;
|
||||
use Net::SSH q<sshopen2>;
|
||||
use v5.14;
|
||||
|
||||
use lib '../../';
|
||||
|
@ -165,15 +165,17 @@ sub del {
|
|||
$rndc->delzone($self->zdir, $self->zname);
|
||||
$rndc->reconfig();
|
||||
|
||||
my $ssh = Net::SSH2->new();
|
||||
|
||||
$ssh->connect($self->host);
|
||||
$ssh->auth( username => $self->user);
|
||||
|
||||
my $chan = $ssh->channel();
|
||||
my $file = $self->zdir.'/'.$self->zname;
|
||||
$chan->exec( "rm $file" );
|
||||
$ssh->disconnect();
|
||||
my $host = $self->host;
|
||||
my $user = $self->user;
|
||||
my $cmd = "rm $file";
|
||||
|
||||
sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!";
|
||||
|
||||
close(READER);
|
||||
close(WRITER);
|
||||
|
||||
|
||||
1;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
use warnings;
|
||||
use v5.14;
|
||||
use autodie;
|
||||
use Modern::Perl;
|
||||
use Data::Dump qw( dump );
|
||||
use DNS::ZoneParse;
|
||||
use Net::SSH q<sshopen2>;
|
||||
|
||||
my $host = "pizza";
|
||||
my $user = "karchnu";
|
||||
my $cmd = "ls /";
|
||||
|
||||
sshopen2("$user\@$host", *READER, *WRITER, "$cmd") || die "ssh: $!";
|
||||
|
||||
while (<READER>) {
|
||||
chomp();
|
||||
print "$_\n";
|
||||
}
|
||||
|
||||
close(READER);
|
||||
close(WRITER);
|
||||
|
Reference in New Issue