Thread nslookup nicht auflösbare hosts in datei schreiben
(9 answers)
Opened by draekster at 2010-06-14 14:13 Code (perl): (dl
)
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); EDIT: Keine Anfühungszeichen: my @nslookup=qx{nslookup $HOST}; Last edited: 2010-06-14 14:49:24 +0200 (CEST) |