Link to home
Start Free TrialLog in
Avatar of 3XLcom
3XLcom

asked on

strange simple error

there are 3 part of errors that we get

1. the beginning errors
2. in the code you should see if ($reason eq "mbps" ) {
but it still applie else part of if

3. why do we get numeric  error :S

[root@sflow islemler]# perl deneme.pl
Unquoted string "paketlimiti" may clash with future reserved word at deneme.pl line 19.
Unquoted string "trafiklimiti" may clash with future reserved word at deneme.pl line 23.
Name "main::paketlimiti" used only once: possible typo at deneme.pl line 4.
Name "main::trafiklimiti" used only once: possible typo at deneme.pl line 5.
Argument "trafiklimiti" isn't numeric in numeric gt (>) at deneme.pl line 23, <$fh> line 1.
paket limiti asildi
mbps

178.20.230.51 35mbps
1387666838 178.20.230.51 35 mbps
paket limiti asildi
pps

178.20.230.51 3072pps
1387666838 178.20.230.51 3072 pps
paket limiti asildi
mbps

178.20.227.86 11mbps
1387666838 178.20.227.86 11 mbps
paket limiti asildi
pps

79.110.81.134 1536pps
1387666838 79.110.81.134 1536 pps
paket limiti asildi
mbps

178.20.230.51 32mbps
1387666839 178.20.230.51 32 mbps
paket limiti asildi
pps

178.20.230.51 3328pps
1387666839 178.20.230.51 3328 pps

Open in new window










use warnings;

 $paketlimiti = 2500;
 $trafiklimiti = 10;

open(my $fh, '-|', 'sflowtool -4 -p 3601  | /scripts/DoSTargets') or die $!;
while (my $line = <$fh>) {

#print ((split(/ /, $line))[1],"\n");


my $ip  = (split(/ /, $line))[1];
my $size = (split(/ /, $line))[2];
my $reason = (split(/ /, $line))[3];


if ($reason eq "mbps" ) {
        if ($size >  paketlimiti) {
                print "trafik limiti asildi \n";
        }
}else{
        if ($size >  trafiklimiti) {
                print "paket limiti asildi \n";
        }
}

print $reason . "\n";
print $ip." ".$size.$reason;
print $line;
}

close $fh;

Open in new window

Avatar of ozo
ozo
Flag of United States of America image

splain
/opt/local/bin/splain: Reading from STDIN
Unquoted string "paketlimiti" may clash with future reserved word at deneme.pl line 19.
Unquoted string "paketlimiti" may clash with future reserved word at deneme.pl
      line 19 (#1)
    (W reserved) You used a bareword that might someday be claimed as a
    reserved word.  It's best to put such a word in quotes, or capitalize it
    somehow, or insert an underbar into it.  You might also declare it as a
    subroutine.

Name "main::paketlimiti" used only once: possible typo at deneme.pl line 4.
Name "main::paketlimiti" used only once: possible typo at deneme.pl line 4 (#2)
    (W once) Typographical errors often show up as unique variable names.
    If you had a good reason for having a unique name, then just mention it
    again somehow to suppress the message.  The our declaration is
    provided for this purpose.
   
    NOTE: This warning detects symbols that have been used only once so $c, @c,
    %c, *c, &c, sub c{}, c(), and c (the filehandle or format) are considered
    the same; if a program uses $c only once but also uses any of the others it
    will not trigger this warning.

Argument "trafiklimiti" isn't numeric in numeric gt (>) at deneme.pl line 23, <$fh> line 1.
Argument "trafiklimiti" isn't numeric in numeric gt (>) at deneme.pl line 23,
      <$fh> line 1 (#3)
    (W numeric) The indicated string was fed as an argument to an operator
    that expected a numeric value instead.  If you're fortunate the message
    will identify which operator was so unfortunate.



Did you mean to say
     if ($size >  $paketlimiti) {
Avatar of 3XLcom
3XLcom

ASKER

yes    if ($size >  $paketlimiti) { this part is not wroking correctly check the output

trafik limiti asildi  8>10
178.20.228.75 8mbps
1387668213 178.20.228.75 8 mbps
trafik limiti asildi  8>10
95.7.67.146 8mbps
1387668214 95.7.67.146 8 mbps
trafik limiti asildi  41>10
185.9.156.83 41mbps





#use strict;
use warnings;

my $paketlimiti = 2500;
my $trafiklimiti = 10;

open(my $fh, '-|', 'sflowtool -4 -p 3601  | /scripts/DoSTargets') or die $!;
while (my $line = <$fh>) {

#print ((split(/ /, $line))[1],"\n");


my $ip  = (split(/ /, $line))[1];
my $size = (split(/ /, $line))[2] + 0;
my $reason = substr((split(/ /, $line))[3],0,-1);


if ($reason eq 'mbps' ) {
        if ($size >  paketlimiti){
                print "trafik limiti asildi  " .$size.">".$trafiklimiti."  \n";
        }else{
                print "trafik limiti asildi  " .$size."<".$trafiklimiti."  \n";
        }
}else{
        if ($size >  trafiklimiti) {
                print "paket limiti asildi \n";
        }
}

print $ip." ".$size.$reason."\n";
print $line;
}

close $fh;

Open in new window

Avatar of 3XLcom

ASKER

that worked but why my variable not acting like a numeric value ;

  
 if ($size >  10){
                print  $size2." trafik limiti asildi  " .$size.">".$trafiklimiti."  \n";
        }else{
                print $size2." trafik limiti asildi  " .$size."<".$trafiklimiti."  \n";
        }

Open in new window

If you mean $size, what was its value?
ASKER CERTIFIED SOLUTION
Avatar of FishMonger
FishMonger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 3XLcom

ASKER

thanks