summaryrefslogtreecommitdiff
path: root/scripts/vyatta-ping
blob: d6561b291647cf18eca2a9af0076c4ccb440af9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /usr/bin/perl
#
# Wrapper around ping

use strict;
use warnings;
use NetAddr::IP;
use feature ":5.10";

my $host = $ARGV[0];
my $ip = new NetAddr::IP $host;
die "Unknown host: $host\n"
    unless defined($ip);

given ($ip->version()) {
    when (4) {
	exec { '/bin/ping' } 'ping', @ARGV
	    or die "Can't exec ping";
    }
    when (6) {
	exec { '/bin/ping6' } 'ping6', @ARGV
	    or die "Can't exec ping6";
    }
    default {
	die "Unknown address: $host\n";
    }
}