Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
There's more than one way to do things
 
PerlMonks  

Re: Ping sweep with reporting

by StarkRavingCalm (Sexton)
on May 16, 2007 at 23:23 UTC ( #615902=note: print w/ replies, xml ) Need Help??


in reply to Ping sweep with reporting

Ok, so I have updated the script with the suggestions. I now looks like this:

#!/usr/bin/perl use strict; use warnings; my $ping = "/bin/ping"; while (<DATA>){ chomp; my $ping_out = `$ping $_ 2> /dev/null`; chomp ($ping_out); if ($ping_out !~ /bytes from/) { print "$_ isn't pinging\n"; } else { print "$_ is up\n"; } __DATA__ SERVER01 SERVER02

But.. I receive this when I run it:

[root@stewie ~]# perl 615424.pl Missing right curly or square bracket at 615424.pl line 17, at end of +line syntax error at 615424.pl line 17, at EOF Execution of 615424.pl aborted due to compilation errors.

Any clues??

Edit: g0n - code tags


Comment on Re: Ping sweep with reporting
Select or Download Code
Re^2: Ping sweep with reporting
by Fletch (Chancellor) on May 17, 2007 at 00:16 UTC

    Hard to tell since you didn't use <code></code> tags around it, but you're missing the } to close the while loop on or around line 17 of your source (before the DATA marker). Just like the error message says.

    Seems to be a lot of that going around today. Did someone declare today "'Ignore the simple error message which explicitly states what's wrong' Day" and I just didn't get the memo?

Re^2: Ping sweep with reporting
by liverpole (Monsignor) on May 17, 2007 at 00:53 UTC
    Hi StarkRavingCalm,

    As Fletch says, it looks like you're simply missing the '}' where marked below:

    #!/usr/bin/perl use strict; use warnings; my $ping = "/bin/ping"; while (<DATA>) { chomp; my $ping_out = `$ping $_ 2> /dev/null`; chomp ($ping_out); if ($ping_out !~ /bytes from/) { print "$_ isn't pinging\n"; } else { print "$_ is up\n"; } # <--- You're missing a '}' right here to end the while { } loop __DATA__ SERVER01 SERVER02

    Was there some reason that "Missing right curly or square bracket" didn't lead you to that conclusion?

    And do you understand how to put <code> and </code> tags around your post so that it's readable?  If not, pay close attention when you hit "preview".  If it doesn't look right, don't click the "create" button until it does!  (You can continue clicking on "preview" until the post displays correctly).


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/
      Thanks for the help. I'm very new to Perl so some of this stuff can\will allude me unfortunaltly. I did see the error but what threw me off was the curly bracket right above where it said it was needed. And I'll pay more attention to my previews ; )

      Let me try adding the bracket and I'll post my results.
      Thanks!

        Ok, here's what I have: <code> #!/usr/bin/perl use strict; use warnings; my $ping = "/bin/ping"; while (<DATA>) { chomp; my $ping_out = `$ping $_ 2> /dev/null`; chomp ($ping_out); if ($ping_out !~ /bytes from/) { print "$_ isn't pinging\n"; } else { print "$_ is up\n"; } } __DATA__ myserver02 <code/> And here's the output: root@stewie ~# perl pingsweep_pm.pl isn't pinging Thoughts?
        Ok, here's what I have:
        #!/usr/bin/perl use strict; use warnings; my $ping = "/bin/ping"; while (<DATA>) { chomp; my $ping_out = `$ping $_ 2> /dev/null`; chomp ($ping_out); if ($ping_out !~ /bytes from/) { print "$_ isn't pinging\n"; } else { print "$_ is up\n"; } } __DATA__ myserver02

        And here's the output:
        root@stewie ~# perl pingsweep_pm.pl isn't pinging

        Thoughts?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://615902]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2014-04-20 03:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls