From owner-freebsd-questions Fri Feb 5 06:17:14 1999 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA22578 for freebsd-questions-outgoing; Fri, 5 Feb 1999 06:17:14 -0800 (PST) (envelope-from owner-freebsd-questions@FreeBSD.ORG) Received: from postoffice.onu.edu (postoffice.onu.edu [140.228.10.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA22570 for ; Fri, 5 Feb 1999 06:17:12 -0800 (PST) (envelope-from r-beer@onu.edu) Received: from [140.228.15.35] (asterion.onu.edu [140.228.15.35]) by postoffice.onu.edu (8.8.8/8.8.8) with ESMTP id JAA12459; Fri, 5 Feb 1999 09:15:55 -0500 (EST) (envelope-from r-beer@onu.edu) Message-Id: In-Reply-To: <3.0.5.32.19990205001838.03baa980@ccsales.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Fri, 5 Feb 1999 09:21:55 -0500 To: "Randy A. Katz" , questions@FreeBSD.ORG From: Robert Beer Subject: Re: A Perl Question Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG At 3:18 AM -0500 2/5/1999, Randy A. Katz wrote: >I'm trying to use gethostbyaddr and it is returning blank: > >$ipaddress = "216.0.22.30"; >($name, $aliases, $addrtype, $length, @addrs) = >gethostbyaddr($ipaddress,AF_INET); >print "Name: $name\n"; >print "Aliases: $aliases\n"; >print "Type: $addrtype\n"; >print "Length: $length\n"; >foreach $p (@addrs) { > print "A:$p\n"; >} >exit; > >I grepped for AF_INET in /usr/include and there is nothing there, I did a >man on gethostbyaddr and AF_INET is the only parameter listed for type??? Here is an example I had: #!/usr/local/bin/perl for (@ARGV) { split(/\./); splice(@_, $#_, 0, (0) x (4-@_)); # inet_addr conversion @hostent = gethostbyaddr(pack(C4, @_), 2); printf "[%s] is %s\n", join('.', @_), $hostent[0] || ""; } It looks like the IP address format is your problem. --- Bob Beer Ohio Northern University, Academic Computer Services, Ada, OH 45810 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message