0
我有一個腳本,它允許我在輸入一個可以轉發到DNS服務器的IP地址後查找主機名。如何使用Perl爲DNS查找配置「檢查錯誤」?
但是,即使一切正常,程序似乎無法打印出我想要的示例如果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 $host = hostname();
my $hostname = $userchoice;
my $packed_ip = gethostbyname("$hostname");
my $ip_address = inet_ntoa($packed_ip) or system("clear"), system("/root/Desktop
/showdns.pl"), die("Can't resolve $hostname: $!\n ,try again");
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");
可有人請給出代碼一些建議嗎?
爲了澄清,'|'是按位或運算符,'||'是邏輯或運算符。換句話說,當你正在進行數學運算時,你只能看到'|'。 – 2010-09-27 08:12:31
它只有在失敗時激活,「或死」被認爲是激活的。 – JavaNoob 2010-09-27 08:21:00
@JavaNoob:更新了我的答案 – ysth 2010-09-27 15:37:08