#14011 - 2001-11-07 06:27 PM
GetHostByAddr
|
Anonymous
Anonymous
Unregistered
|
I want to translate an IP address into a machine name so I can identify PC's on our network I know WSOCK32.DLL has something called !gethostbyaddr, and I presume it can be called by the new COM automation feature. Unfortunately I have no idea how to do this
|
|
Top
|
|
|
|
#14013 - 2001-11-07 08:53 PM
Re: GetHostByAddr
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
working with the IP stack from a scripting language... is kinda in the hard side.If you have one of MS's programming suites installed, then you can do it, otherwise, you have to install a 3rd party api control. we went over this stuff in this thread here. http://kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=2&t=002284 your best bet would be to shell out and do a ping command and grab the information that way. code:
$ip = "208.169.161.27"shell '%comspec% /c ping -a -n 1 -w 0 $ip | find /i "[$ip]" > %temp%\temp.txt' $nul = open(1,"%temp%\temp.txt",2) $data = readline(1) $nul = close(1) del "%temp%\temp.txt" $ipname = substr($data,9,instr($data,"[$ip]")-10) ? $ipname
Bryce
|
|
Top
|
|
|
|
#14018 - 2001-11-09 03:34 PM
Re: GetHostByAddr
|
Anonymous
Anonymous
Unregistered
|
Well however much I wanted a trivial solution, at least I know I havent asked a stupid question! Thanks for the offer Richard. I have seen a similar thing (probably on NONAGS), but I really wanted a UDF so that everything is in the one file. The Ping parsing solution therefore seems to be the one to go for. (have you noticed that you can't use a DOS pipe symbol in immediate mode, but it works in scripts - Weird?)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2870 anonymous users online.
|
|
|