我目前有一个DNS反向查找脚本,可以工作,但是有一个小小的问题可以输出DNS系统错误。如何在Perl中为DNS解析输出错误?
的问题是这样的:假/错的互联网地址名称等。“www.whyisthednsnothappening.com”
- 用户按键脚本将然后使用系统清除屏幕(清)
- 脚本然后将打印“无法解析DNS的错误是由于:各种系统错误”
- 脚本重新引导用户回到同一菜单/脚本的名称地址,再次输入。
所以主要问题是现在第3步该脚本只显示我“无法解析DNS的错误是由于:BLANK”哪个BLANK是假设显示像“坏ARG错误长度为Socket :: inet_ntoa,长度为0,应为4,位于./showdns.pl第28行,<>第1行。“并且DNS脚本的菜单位于错误打印的下方。
的代码:
#!/usr/bin/perl
use IO::Socket;
use warnings;
use strict;
use Term::ANSIColor;
use Socket;
use Sys::Hostname;
print "\nYou are now in Show DNS IP Address!\n\n";
print "*************\n";
print "|DNS Address|\n";
print "*************\n";
print "\nPlease enter a hostname that you wish to view\n\n";
print "\n\nEnter the hostname of Choice Here: ";
my $userchoice = <>;
chomp ($userchoice);
my $hostname = $userchoice;
my $i_addr = scalar(gethostbyname($hostname || 'localhost'));
if (! defined $i_addr) {
my $err = $!;
my $herr = int herror(const char *s);
system('clear');
print("Can't resolve $hostname: $herr, try again");
exec("/root/Desktop/showdns.pl");
exit();
}
my $name = inet_ntoa($i_addr);
my $coloredText = colored($name, 'bold underline blue');
print "\n\nThe hostname IP address is: $coloredText\n\n";
print "Press enter to go back to the main menu\n\n";
my $userinput2 = <>;
chomp ($userinput2);
system("clear");
system("/root/Desktop/simpleip.pl");
可有人请给出代码的建议吗?谢谢!
的[?我该如何配置使用Perl“检查错误”的DNS查询]可能重复(http://stackoverflow.com/questions/3801705/how-can-i-配置检查用于错误的Dns-lookup-using-perl) – 2010-09-29 15:36:50
阅读到评论的最后!而布莱恩没有进攻,但你的表现就像一个跟踪者,如果你停止跟踪我,他会非常感激...... – JavaNoob 2010-09-30 00:56:47