You can use the system() and exec() functions within Perl to pipe out of the Perl program and run another program.
For example, in DOS, if you have a Perl script that you want to use DOS's cd command to find the current working directory, you would do something like:
[tt]
#perl code up above
system("CD"
[/tt]
That will print the current directory, as you would do in DOS.
Therefore, if fping and ping are programs on your machine, and I assume they are, then you can do something like:
hello cgi,
Can you give us a little more detail.
What OS are you using?
What web server?
Do you already have a list of the other hosts? Or, do you need to find them?
Do you know Perl or another language appropriate for this chore?
(most answers in this forum use Perl.... Perl would work well,
other languages, obviously, would work also)
Given some detail, I expect you will get some guidance (maybe not free code) ...but, some good guidance as to how to pursue your task.
hi
goBoating
I'm using Window as OS
and the web Server is Apache Server run on Red Hat Linux
yup
i got a list of hosts that i wish to ping and save them in a text file.
the text file save in the same dir as the fping script
izzit detail enough
so can u help me??
I'm still not sure which OS you are using. You write that you are 'using Window as OS' and then mention RH Linux, which is also an OS. I'm going to guess your actually going to be running this on the RH Linux. You should be able to tweak this a little to get it to run from the command prompt. Once that works, we can work on getting it to run as a CGI. Vic's approach will run the fping, but, it will not give you back the output from fping. Rather, it will only return the exit status of fping, 0 or 1. To catch the output from fping, you will need to open a pipe to it. I don't see any reason this would not run on a Win OS or RH.
#!/usr/local/bin/perl
# create a list of the IP addresses to ping.
@ips = ('123.258.35.36','IP2','IP3');
# open an output file to record the results
open(OPF,">someFileName" or die "Failed to open someFileName, $!\n";
# foreach ip in the list, run fping.
foreach $ip (@ips)
{
print OPF "$ip - \n";
# open a pipe (child process to each fping
open(PIPE,"fping $ip |" or die "Failed to open PIPE to $cmd, $!\n";
while(<PIPE>) { print OPF "$_"; }
close PIPE;
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.