Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
    @HOSTS = ("", "", "", "");
    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, Sven, 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
Format your code in a sane way. Tell us what doeesn't work excactly, with error messages etc. – Sven May 26 '12 at 10:52

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

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