Guest_imported
New member
- Jan 1, 1970
- 0
- 0
- 0
I have a script that does ping on my Solaris 7 OS but I need it to email me if an IP address does not ping.
I tried to use the Unix exit status to find unsuccessful exit status due to bad ping ($? = EXIT STATUS...IF 0 THEN IT SUCCEEDED, IF
OTHER THEN FAILED) then I would be able to email myself if an IP address didnt ping. My exit status check is not
working. Anyone have a better idea of how I could do this??
#!/usr/local/bin/perl
@a = (<DATA>);
$s = system("$?"
foreach (@a)
{
system("/usr/sbin/ping $_"
print system("$?\n"
if ( $? != 0)
{
print "Could not ping host.";
}
else
{
print "Ping successful.\n";
}
}
close(DATA);
__DATA__
111.111.111.111
222.222.222.333
232.454.556.565