1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| #!/usr/bin/perl --
use DBI;
use POSIX qw(strftime mktime);
use POSIX qw(strftime mktime);
use Getopt::Std;
use strict;
use warnings;
use Data::Dumper;
use Net::OpenSSH;
###################################################
# #
# Variables #
# #
###################################################
my $ssh;
my $host;
my $user_name;
my $password;
my $dir;
my @logInstalFiles = ("readme","readme2","readme3","readme4");
my @logAppliFiles = ("readme","readme2","readme3","readme4");
###################################################
# #
# Programme #
# #
###################################################
##################################################
### Ouverture du fichier de conf à remplir ###
##################################################
open(FILE,">config_p.txt") or die ("Erreur d'ouverture du fichier\n");
#########################
### Connexion SSH ###
#########################
print "==> Connexion SSH en cours...\n";
$host = "xxx.xxx.xxx.xxx";
$user_name = "login";
$password = "password";
$ssh = Net::OpenSSH->new($host,user => $user_name, password => $password);
$ssh->error and die "unable to connect to remote host : ". $ssh->error;
print "Connexion OK\n";
##############################################
### Vérification des logs installation ###
##############################################
print(FILE "01 - Vérification des logs installation\n\n");
$ssh->system("grep * /chemin_vers_les_differents_fichiers/") or
die "remote command failed : " . $ssh->error;
<STDIN>;
print "\n";
# Step 2
$ssh->system("cd xxxxxxx/") or
die "remote command failed : " . $ssh->error;
foreach my $fichier (@logInstallFiles)
{
print(FILE "$fichier\n");
$ssh->system("grep * $fichier") or
die "remote command failed : " . $ssh->error;
print FILE join("",<RESULT>);
}
#####################################
### Vérification des services ###
#####################################
print(FILE "\n02 - Vérification des services\n\n");
open(RESULT,"script.sh|") or die $!;
print FILE join("",<RESULT>); |
Partager