Bonjour,
je voulais me faire un petit script en perl (que je ne maitrise pas vraiment) pour envoyer des fichiers en local sur mon poste vers des serveurs.
Mes insultes
voici le code :Use of uninitialized value in array element at D:\Utils\Deploiement_scripts.pl line 46, <> line 1.
Use of uninitialized value in string at D:\Utils\Deploiement_scripts.pl
line 46, <> line 1.
Use of uninitialized value in concatenation (.) or string at D:\Utils\Deploi
ement_scripts_prc.pl line 46, <> line 1.
Use of uninitialized value in concatenation (.) or string at D:\Utils\Deploi
ement_scripts.pl line 46, <> line 1.
Use of uninitialized value in concatenation (.) or string at D:\Utils\Deploi
ement_scripts.pl line 46, <> line 1.
put , /TOOLS/scripts/No such file or directory
Merci d'avance pour les lumières que vous pourrez m'apporter
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #"!/usr/bin/perl use warnings; use strict; use DBI; use Net::SSH2; use File::Basename; use File::Find; ############### Parametres ######################################################## my $BaseDeDonnees = "la base"; my $NomHote = "serv"; my $login = "XXX"; my $MotDePass = "XXXX"; my $port = "3306"; my $REP_DIST = "/TOOLS/scripts"; my $REP_LOC = "d:/TOOLS/scripts"; my $req; my $HOSTNAME; my $serv; my @LISTE_FILES; my $user = $ENV{USERNAME}; print "$user\n"; print "Votre MDP : "; chomp( my $MDP = <> ); ########################## Script ################################################## my $count = 1; find( { wanted => \&list_files, }, $REP_LOC ); my $dbh = DBI->connect( "dbi:mysql:dbname=$BaseDeDonnees;host=$NomHote;port=$port", $login, $MotDePass ) or die "Connection impossible a la base de donnees $BaseDeDonnees !"; $req = $dbh->prepare("select NAME_SERVER from LIST;"); $req->execute() or die "Echec requete\n"; while (my @row = $req->fetchrow_array){ print "$row[0]\n"; $serv = $row[0]; my $ssh2 = Net::SSH2->new(); $ssh2->connect($serv) or die "Can't connect to $serv: $!\n"; $ssh2->auth_password( $user, $MDP ) or die "Authentication failed: $!\n"; my $chan1 = $ssh2->channel(); $chan1->exec("mkdir -p $REP_DIST") or die "1 $!\n"; # $chan1->close; foreach my $v (@LISTE_FILES) { $ssh2->scp_put( "$LISTE_FILES[$v][1]", "$REP_DIST/$LISTE_FILES[$v][2]" ) or die "put $LISTE_FILES[$v][1], $REP_DIST/$LISTE_FILES[$v][2]$ !\n"; } $chan1 = $ssh2->channel(); $chan1->exec("chmod -R 775 $REP_DIST") or die "3 $!\n"; } ############ Fonction ############## sub list_files { if ( -f $File::Find::name && /\.*$/i ) { $LISTE_FILES[$count][1] = $File::Find::name; $LISTE_FILES[$count][2] = $_; print "$count : $LISTE_FILES[$count][1] - $LISTE_FILES[$count][2]\n"; $count++; } }![]()
Partager