in reply to Argument isn't numeric in numeric ge

What is this ^G? A bell character? Not a cipher, I think. How do you get the values?
  • Comment on Re: Argument isn't numeric in numeric ge

Replies are listed 'Best First'.
Re^2: Argument isn't numeric in numeric ge
by natxo (Scribe) on Dec 09, 2011 at 14:19 UTC
    I do not know where it comes from. The script is a nagios check to monitor the updates.spamassassin.org channel:
    #!/usr/bin/perl use warnings; use strict; use Mail::SpamAssassin; use Net::DNS; # variables my ( $sa_version, $rev_sa_version, $SA, $update_dir, $version_on_disk, $LOCAL_STATE_DIR, $resolver, $query, $version_dns, $sa_channel ); # get the SpamAssassin version from the Perl module $sa_version = Mail::SpamAssassin::Version(); # reverse this number. We will need it for a txt forware query later $rev_sa_version = join(".", reverse split(/\./, $sa_version) ) ; # sa channel we want to monitor $sa_channel = "updates.spamassassin.org"; # get the local state dir update path $LOCAL_STATE_DIR = '/var/lib/spamassassin'; $SA = Mail::SpamAssassin->new( { LOCAL_STATE_DIR => $LOCAL_STATE_DIR, } ); $update_dir = $SA->sed_path('__local_state_dir__/__version__'); # inside $update_dir, get the line starting with "# UPDATE " # save the version in $version_on_disk if ( -e "$update_dir/updates_spamassassin_org.cf" ) { open (CF, "$update_dir/updates_spamassassin_org.cf" ) or die "$!\n +"; while (<CF> ) { last unless /^# UPDATE\s+[A-Za-z]+\s+(\S+)/; $version_on_disk = $1; } } print "$sa_channel channel version on disk is: $version_on_disk\n"; $resolver = Net::DNS::Resolver->new; $query = $resolver->query("$rev_sa_version.$sa_channel", 'txt'); if ( $query ) { for my $rr ( $query->answer ) { $version_dns = $rr->rdata; } } print "$sa_channel channel dns txt query version is $version_dns\n"; print "[$version_on_disk]\t version on disk\n"; print "[$version_dns]\t version dns\n"; if ( "$version_on_disk" >= "$version_dns" ) { print "OK: the $sa_channel version on disk is up to date: $version +_on_disk\n"; exit 0; } else { print "WARNING: there is a newer version available for SpamAssassi +n $sa_channel rules (on disk version is $version_on_disk, new version + is $version_dns. Run sa-update -D as root to upgrade your SpamAssass +in channel version.\n"; exit 1; }
    I added the [] chars around $version_on_disk and $version_dns to make sure no strange characters were coming on the variables. They print correctly on the terminal.

      Specifically use Data::Dumper and $Data::Dumper::Useqq=1;(!!) to see control characters in strings

      I added the [] chars around $version_on_disk and $version_dns to make sure no strange characters were coming on the variables. They print correctly on the terminal.
      How can you detect a sound in brackets? Use Data::Dumper (plus $Data::Dumper::Useqq=1; as advised by jethro) or pipe your output to a hexdump.
      Updated.
        ok:
        use Data::Dumper; print Dumper $version_on_disk, "disk"; print Dumper $version_dns, "dns";
        gives
        $VAR1 = '1195874'; $VAR2 = 'disk'; $VAR1 = '1195874'; $VAR2 = 'dns';
        Update: with $Data::Dumper::Useqq = 1 ; I see an extra char indeed:
        $VAR1 = 1195874; $VAR2 = "disk"; $VAR1 = "\a1195874"; $VAR2 = "dns";
        So now I have to figure out why it gets here and how to get rid of it. Thanks! (no votes left today, I'll appoint votes tomorrow)

      Can you show the content of the file "$update_dir/updates_spamassassin_org.cf" ?

        a partial head of the file (only interested on the first line)
        # UPDATE version 1195874 include updates_spamassassin_org/10_default_prefs.cf include updates_spamassassin_org/20_advance_fee.cf include updates_spamassassin_org/20_aux_tlds.cf include updates_spamassassin_org/20_body_tests.cf include updates_spamassassin_org/20_compensate.cf include updates_spamassassin_org/20_dnsbl_tests.cf include updates_spamassassin_org/20_drugs.cf include updates_spamassassin_org/20_dynrdns.cf include updates_spamassassin_org/20_fake_helo_tests.cf