Leser: 19
1 2 3
if ($nslookup[-1] =~ m/wurde von .* nicht gefunden: Non-existent domain/) { # not found, write to different file {
Guest draekstermit "$nslookup[-1] =~ m/wurde von .* nicht..." (oder ähnlichem) hab ichs schon versucht aber hat nicht geklappt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
*** HOST1 wurde von DNS.Domain.de nicht gefunden: Non-existent domain $VAR1 = [ "Server: DNS.Domain.de\n", "Address: DNS.IP\n", "\n" ]; *** HOST2 wurde von DNS.Domain.de nicht gefunden: Non-existent domain $VAR1 = [ "Server: DNS.Domain.de\n", "Address: DNS.IP\n", "\n" ]; $VAR1 = [ "Server: DNS.Domain.de\n", "Address: DNS.IP\n", "\n", "Name: HOST3\n", "Address: IP\n", "\n" ];
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
#!/usr/bin/perl use strict; use warnings; my $HOST='www.xx.yy'; my $host_log='hosts.log'; my $host_err='hosts.err'; open(my $lh,'>>',$host_log) or die("ERROR open $host_log ($!)\n"); open(my $eh,'>>',$host_err) or die("ERROR open $host_err ($!)\n"); my @nslookup=qx{nslookup $HOST}; if(@nslookup) { if($nslookup[-1]=~/\Qserver can't find/) { print $eh @nslookup; } else { print $lh @nslookup; } } else { print $eh "ERROR EXEC nslookup $HOST ($?)\n"; } close($eh); close($lh);