Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
824 connectés 

  FORUM HardWare.fr
  Programmation
  Perl

  Script Perl

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Script Perl

n°2127313
titiom06
Posté le 20-02-2012 à 16:15:58  profilanswer
 

Bonjour j'ai un souci avec un script ,
********************************
 
#!/usr/bin/perl
use warnings;
use strict;
use POSIX;
 
#LocalTime2UnixTime :
my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =localtime(time);
$year += 1900;
my $local_unixtime = mktime ($sec, $min, $hour, $mday, $mon+1, $year-1900,-1,-1,-1);
 
 
my $login0 ;
my $login1;
my $login2 ;
my $login_time;
my $feature;
my @feature = qw(nano nano/ace_cosim nano/gui nano/power );
 
 
foreach my $feat (@feature) {
print "FLAG lmstat : lmstat -c 12345\@toto -f $feat \n";
        my @command=`/home/toto/lmutil lmstat -c 12345\@toto -f $feat`;
 
        foreach my $check  (@command) {
        if ($check =~ /start/) {
                print "FLAG1 resultat command $check\n";
                my @check=split (/ /,$check);
                $login0=$check[4];
                $login0=$login1 ;
                # Calcul d'utilisation
                my $time_start=$check[13];
                my $date_start=$check[12];
                chomp ($time_start);
                chomp ($date_start);
 
#               On écrase localTime avec les valeur trouvée
                ($hour, $min ) = split/:/,$time_start;
                ($mon, $mday ) = split/\//,$date_start;
 
#               TimesUse2UnixTimes
                my $unixtime = mktime ($sec, $min, $hour, $mday, $mon, $year- 1900,-1,-1,-1 );
                my $diff=  $local_unixtime - $unixtime ;
 
                my $heures_util=int($diff / 3600);
 
#               Envoi du temps abusif
                if ($heures_util >=24 || $login1 == $login2 ) {
                        $login_time=$login1;
                        $feature=$feat;
                        print " FLAG2 LoginTime Feature : $login_time $feature\n";
                        $login0=$login2;
                }
        }
}
 
}
 
**************************************
Le programme me retourne :
 
FLAG lmstat : lmstat -c 12345@toto -f nano  
FLAG1 resultat command     slesne pascal /dev/pts/31 (v2007.030) (toto/12345 223), start Mon 2/20 15:49
 
Use of uninitialized value in numeric eq (==) at ./nano.pl line 51.
Use of uninitialized value in numeric eq (==) at ./nano.pl line 51.
Use of uninitialized value in concatenation (.) or string at ./nano.pl line 54.
 FLAG2 LoginTime Feature :  nano
FLAG lmstat : lmstat -c 12345@toto -f nano/ace_cosim  
FLAG lmstat : lmstat -c 12345@toto -f nano/gui  
FLAG lmstat : lmstat -c 12345@toto -f nano/power  
FLAG1 resultat command     slesne pascal /dev/pts/31 (v2007.030) (toto@12345 337), start Mon 2/20 15:49
 
Use of uninitialized value in numeric eq (==) at ./nano.pl line 51.
Use of uninitialized value in numeric eq (==) at ./nano.pl line 51.
Use of uninitialized value in concatenation (.) or string at ./nano.pl line 54.
 FLAG2 LoginTime Feature :  nano/power
 
 
L'erreur doit venir de la dernière séquence du programme je pense.
 
Merci d'avance,

mood
Publicité
Posté le 20-02-2012 à 16:15:58  profilanswer
 

n°2127379
gilou
Modérateur
Modzilla
Posté le 20-02-2012 à 19:59:37  profilanswer
 

$login1 == $login2
Ni l'un ni l'autre ne sont initialisés à quoi que ce soit par ton code.
A+,


---------------
There's more than what can be linked! --    Iyashikei Anime Forever!    --  AngularJS c'est un framework d'engulé!  --

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Perl

  Script Perl

 

Sujets relatifs
[Perl] Demande authentification avec le script mais pas avec Firefoxcgi perl: comment fermer la connexion serveur en continuant le script
[PERL] aide script pour alimenter SGBD MySQLTitre d'un script CGI Perl
[perl]script sauvegarde, telnetScript PERL & PHP pour interface CISCO avec carte CSM
Le répertoire courant de mon script perl est " / " ?!Ajouter un espace ds un script perl sous Windows
Lancement script PHP depuis script PERLHelloworld en script perl cgi
Plus de sujets relatifs à : Script Perl


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR