0

Stackoverflow 社区,

我是 PERL 脚本的新手,需要帮助 [此脚本的一部分来自 Internet 资源] 以对文件中的 IP 地址列表进行 nslookup 并遍历每个地址,直到我完成。如果域名不存在则执行 X,如果存在则执行 Y。

以下信息:

-existent - is a key word when nslookup aborts
name - is a key word when it works
listofhosts - is my ip address list

谢谢您的任何帮助,非常感谢

#!/usr/bin/perl
#!c:\perl64\bin

use strict;
use warnings;

my $noname=-existent;
my $name=name;

open IPADDRESSES,("c:\\perl64\\scripts\\listofhosts.txt") or die("File could not be opened :$!");
my @list=<IPADDRESSES>;
foreach my $list(@list);
my $results=`nslookup $list`;
CHOMP ($list);
if ($noname) {
    print ("no name")}
elsif ($name){
    print ("IP address $list:\n");
    print ("=\n");
    print ("DNS name:$results\n");
}

close (IPADDRESSES); 
4

1 回答 1

1

还尝试查看Net::Nslookup而不是使用nslookup ...

于 2014-10-16T15:23:10.567 回答