Jemand zu Hause?
1
2
3
4
5
open(my $sshfind, "| ssh -T -l user maschine");
print $sshfind "ssh hier will ich weiterpingen und checken ob eine maschine xx da ist!!!\n";
print $sshfind "exit\n";
print $sshfind "exit\n";
close($sshfind) or die "$!";
1
2
3
4
5
6
7
8
9
10
11
$ ssh localhost ping -c 2 localhost
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=1 ttl=64 time=0.033 ms
64 bytes from localhost.localdomain (127.0.0.1): icmp_seq=2 ttl=64 time=0.021 ms
--- localhost.localdomain ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.021/0.027/0.033/0.006 ms
RC:0 $ ssh localhost ping -c 2 localhosta
ping: unknown host localhosta
RC:2 $
1
2
3
4
5
open(my $sshfind, "| ssh -T -user maschine1");
print $sshfind "ssh maschine1 ping -c 2 maschine2\n";
print $sshfind "exit\n";
print $sshfind "exit\n";
close($sshfind) or die "$!";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# ... Variablen zuvor deklariert und befuellt # Kommando vorbereiten my @cmd = ( qw( ssh -T -user ), $user01, $machine01, "ping -c 2 $machine02", ); # Kommando ausführen, siehe: perldoc -f system my $rc = system( @cmd ); # Exitcode kontrollieren; siehe perldoc -f system if ( $rc == 0 ) { ## Erfolg } else { ## Mißerfolg }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Check if host ist available
my @cmd_5 = ("ping -c 1 $bmw_host1",);
$rc_5 = system( @cmd_5 );
print "rc5 $!\n";
my @cmd_6 = ("ping -c 1 $bmw_host2",);
$rc_6 = system( @cmd_6 );
print "rc6 $!";
if ($rc_5 == 0) {
print "\n\nHost: $bmw_host1\n\n\n";
$bmw_host = $bmw_host1;
$global_flag_ping = 0;
}
elsif ($rc_6 == 0) {
print "\n\nHost: $bmw_host2\n\n\n";
$bmw_host = $bmw_host2;
$global_flag_ping = 0;
}
else
{
print "\n\nNo host availible\n\n\n";
print "\n Sleep \n";
sleep $download_sleep_time;
$global_flag_ping = 1;
}
Quotehttp://linux.die.net/man/8/pingIf ping does not receive any reply packets at all it will exit with code 1. If a packet count and deadline are both specified, and fewer than count packets are received by the time the deadline has arrived, it will also exit with code 1.
Wie installiert man ein Modul?