aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Yuzhaninov <citrin+git@citrin.ru>2019-07-16 21:53:32 +0100
committerAnton Yuzhaninov <citrin+git@citrin.ru>2019-07-16 21:53:32 +0100
commite2399767b1be6b4c0967f7cfa9e04f8e3cd3f1b0 (patch)
tree8b6430ec2dcf3db2b01e6ea6c6feb8149cd09d3c
parent809cd1e03fd56a9c6fd8af69eb69619e94827e6e (diff)
downloadrspamd-e2399767b1be6b4c0967f7cfa9e04f8e3cd3f1b0.tar.gz
rspamd-e2399767b1be6b4c0967f7cfa9e04f8e3cd3f1b0.zip
[Minor] Fix a check for bgpdump binary
While here sort 'use'.
-rw-r--r--utils/asn.pl22
1 files changed, 10 insertions, 12 deletions
diff --git a/utils/asn.pl b/utils/asn.pl
index d78277459..1ef98c7e5 100644
--- a/utils/asn.pl
+++ b/utils/asn.pl
@@ -2,14 +2,16 @@
use warnings;
use strict;
-use Pod::Usage;
-use Getopt::Long;
+
+use File::Basename;
use File::Fetch;
+use Getopt::Long;
+use IPC::Cmd qw/can_run/;
+use Pod::Usage;
+
use LWP::Simple;
use PerlIO::gzip;
-use File::Basename;
use URI;
-use Data::Dumper;
$LWP::Simple::ua->show_progress(1);
@@ -58,12 +60,8 @@ GetOptions(
pod2usage(1) if $help;
pod2usage( -exitval => 0, -verbose => 2 ) if $man;
-if ( -x bgpdump ) {
- use_bgpdump = $1;
-} else {
- warn "bgpdump is not found will try to use Net::MRT instead, results can be incomplete";
-}
-
+my $bgpdump_path = can_run('bgpdump')
+ or warn 'bgpdump is not found, will try to use Net::MRT instead; results can be incomplete';
sub download_file {
my ($u) = @_;
@@ -134,7 +132,7 @@ foreach my $u ( @{ $config{'bgp_sources'} } ) {
my $parsed = URI->new($u);
my $fname = $download_target . '/' . basename( $parsed->path );
- if ($use_bgpdump) {
+ if ($bgpdump_path) {
use constant {
F_MARKER => 0,
F_TIMESTAMP => 1,
@@ -145,7 +143,7 @@ foreach my $u ( @{ $config{'bgp_sources'} } ) {
F_ORIGIN => 7,
};
- open(my $bgpd, '-|', "bgpdump -v -M $fname") or die "can't start bgpdump: $!";
+ open(my $bgpd, '-|', "$bgpdump_path -v -M $fname") or die "can't start bgpdump: $!";
while (<$bgpd>) {
chomp;