in reply to Re: Argument isn't numeric in numeric ge
in thread Argument isn't numeric in numeric ge
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.#!/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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Argument isn't numeric in numeric ge
by jethro (Monsignor) on Dec 09, 2011 at 14:30 UTC | |
Re^3: Argument isn't numeric in numeric ge
by choroba (Cardinal) on Dec 09, 2011 at 14:22 UTC | |
by natxo (Scribe) on Dec 09, 2011 at 14:30 UTC | |
Re^3: Argument isn't numeric in numeric ge
by Generoso (Prior) on Dec 09, 2011 at 14:26 UTC | |
by natxo (Scribe) on Dec 09, 2011 at 14:35 UTC |