-3
#!/usr/bin/perl
    @HOSTS = ("192.168.14.112", "192.168.14.90", "192.168.160.1", "192.168.160.100");
    my $COUNT = 4;
    my $date =`date`;
    for my $myHost (@HOSTS) {
        **$count = `ping  -c $COUNT $myHost | grep 'received' |awk -F',' '{ print $2 }' |awk '{ print $1 }'`;**
        if ( $count == 0 ){
            print "Host : $myHost is down (pint failed) at $date \n";
            }
        #else {
            #print "\n Host : $myHost is up at $date \n";
            #}
    }

I have set of ip, i want to check the status of given ip but i stuck in execute linux command inside the perl .

$count = ping -c $COUNT $myHost | grep 'received' |awk -F',' '{ print $2 }' |awk '{ print $1 }';

i'm not able to get proper output through given command

user1363308
  • 101
  • 1

1 Answers1

1

Without really knowing what's not working, the first thing that I see when I put your code into a language sensitive editor is that the ' at the end of your line count = ... should be a `.

user9517
  • 115,471
  • 20
  • 215
  • 297