printing output of ping command

From: TapasranjanMohapatra (TapasranjanMohapatra_at_infosys.com)
Date: 02/23/05


Date: Wed, 23 Feb 2005 20:02:57 +0530
To: <beginners@perl.org>

Hi All,
I have a script as follows
----------------------------
my $host = shift;
my $count = shift;
my $result = `ping -c $count $host`;
if($result =~ m/$count packets transmitted, $count packets received/)
{
 $success = 1;
}
print "$result\n";
----------------------------

Now, when I run the script, the ping is executed the result is stored in the $result variable and printed at the last statement. When the count is a big number, I have to wait till the command finishes and then it prints at one shot at the last line.
Is it possible to get the output printed as it is seen while running the ping command? I mean instead of printing at one shot at the end, I want to print line by line as the ping is being executed. Is it possible?

TIA
Tapas



Relevant Pages

  • Re: Random scsi disk disappearing
    ... Such a script exists in the ... New scsi logging level: ... shift 2;; ...
    (Linux-Kernel)
  • Re: [SLE] emailing myself when a ping command fails via crontab????
    ... but I have a perl script to monitor a webserver. ... First the script tries to ping it's DNS servers, ...
    (SuSE)
  • RE: ICMP (Ping)
    ... script to locate vulnerabilities(example point and case: ... Is it good to allow UDP ping packets? ... Guys again, I am not saying that you disable pings and walk away, job ... 300K and you guys are right, it port scans like a freaking demon. ...
    (Security-Basics)
  • Re: How to run script (sleep360) without delaying bootup
    ... I don't think they would mind Now the script you sent this morning which I don't have in front of me I would think could do the job. ... Maybe you could ping then see if there a command to dealy the time servers and then let them run. ... Pinging a server on the Internet isn't really the problem, ...
    (Fedora)
  • RE: Tools for pen test,
    ... You can use something like fping, but if your heart is set on a script, then ... The problem is that tools like PING ... I was wondering has anyone in here had a shell script that can execute tools ... Need to secure your web apps NOW? ...
    (Pen-Test)