my $ausgabe = qx/ping 192.168.0.1/;
my $ausgabe = `ping 192.168.0.1`;
1 2 3 4 5 6
open(my $h, '-|', 'ping -c 1 127.0.0.1') or die($!); while(<$h>) { print "PING: $_"; } close($h) or die($!);
1 2 3 4 5 6 7 8
#!/usr/bin/perl use strict; use warnings; use Net::Ping; my $p = Net::Ping->new(); print "127.0.0.1 is alive.\n" if $p->ping('127.0.0.1'); $p->close();
QuoteIch nutze die Funktion "system()" um z. B. ein Ping auf eine IP-Adresse ausführen.
1 2 3
use Net::Ping; my $p = Net::Ping->new('icmp'); print $p->ping('localhost'); # 1