Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.
#!/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

share|improve this question

closed as not a real question by EightBitTony, SvW, Khaled, MadHatter, Iain May 26 '12 at 11:12

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Vague and off-topic. –  EightBitTony May 26 '12 at 10:40
1  
Format your code in a sane way. Tell us what doeesn't work excactly, with error messages etc. –  SvW May 26 '12 at 10:52
add comment

1 Answer

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 `.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.