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
| #!/usr/bin/perl
use strict;
use warnings;
use Net::FTPSSL;
my $file = '/home/seb/workspace/Islo_People/Configuration';
my $user;
my $mdp;
my $server;
sub new
{
my @parametre = Recherche_parametre();
$user = $parametre[0];
$mdp = $parametre[1];
$server = $parametre[2];
}
sub Recherche_parametre()
{
my $lignes;
my @config;
my @parametre;
open(CONF, "<".$file);
while(defined($lignes = <CONF>))
{
@config = split("=", $lignes);
if($config[0] == 'user')
{
$user=$config[1];
}
if($config[2] == 'mdp')
{
$mdp=$config[3];
}
if($config[4] == 'server')
{
$server=$config[5];
}
@parametre=($user,$mdp,$server);
}
close(CONF);
return @parametre;
}
sub Connection
{
my $etat = "vrai";
my $ftps = Net::FTPSSL->new("$server",
Port=> 21,
Encryption => EXP_CRYPT,
Debug => 1)
or $etat = "faux";
$ftps-> login('$user', '$mdp')
or $etat = "faux";
return $etat;
} |
Partager