jaldama has asked for the wisdom of the Perl Monks concerning the following question:
Howdy! I've spent some time reading about looking up a DNS in perl but am having trouble with my script. Hoping someone could give me a hint as to where I've gone wrong?
#!/usr/bin/perl-w use Socket; if ( $#ARGV != 0 ) { print "Usage: $0 hostname\n"; exit(1); } $userinput = $ARGV[0]; if ($userinput =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ ) { $userinput = $ip; $hostname = gethostbyaddr(inet_aton($ip), AF_INET) or die "Can't R +esolve $ip: $!\n"; print $hostname; } else { $userinput = $name; $ipaddr = gethostbyname($name) or die "Can't resolve $name: $!\n"; $ipaddr = inet_ntoa(inet_aton($name)); print $ipaddr; } ##prints this? $ perl ddlookup.pl wbur.org Can't resolve : No such file or directory
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DNS Lookup
by toolic (Bishop) on Jan 19, 2012 at 19:34 UTC | |
by JavaFan (Canon) on Jan 19, 2012 at 22:24 UTC | |
by Anonymous Monk on Jan 20, 2012 at 03:44 UTC | |
by jaldama (Acolyte) on Jan 19, 2012 at 20:05 UTC | |
|
Re: DNS Lookup
by Khen1950fx (Canon) on Jan 20, 2012 at 10:09 UTC | |
by jaldama (Acolyte) on Jan 20, 2012 at 21:01 UTC |