Notifications
Clear all
[Closed] Obtaining IPs
Mar 14, 2008 6:05 pm
Anyone have any suggestions as to how I might grab the IP addresses of a number of named machines on my network via MXS?
Even better would be if those IPs could populate Mental Ray’s Distributed Rendering list of slaves!
2 Replies
Mar 14, 2008 6:05 pm
I don’t think there’s any particular network commands in 3ds Max, so you might have to do something like…
-- send a ping to hostname (string containing the machine's name)
-- record the output in output.txt
-- DOSCommand 'waits' until the command is done, unlike ShellLaunch
result = DOSCommand "ping -n 1 " + hostname + " > c:\\output.txt"
-- result == 0 : ping worked, machine exists
-- result == 1 : ping didn't work, machine doesn't exist (or timed out or somesuch)
-- open the file
pingFile = openFile "c:\\output.txt" mode:"rtS"
-- <File:c:\output.txt>
-- skip to the line of interest
skipToString pingFile "Pinging "
-- OK
-- get that line
pingLine = readline pingFile
-- "myMachine [192.168.1.1] with 32 bytes of data:"
-- close the file
close pingFile
-- OK
-- get the IP string
ipString = (filterString pingLine " ")[2]
-- "[192.168.2.2]"
-- remove those brackets
ipString = subString ipString 2 (ipString.count - 2)
-- "192.168.2.2"
There may be more efficient utilities out there that get the IP address for a given machine name.
And then there is .NET But I’ve not dabbled with networking code in .NET, ever, so you know as much as I do there
Mar 14, 2008 6:05 pm
<3 .NET
dnsClass = dotNetClass "System.Net.Dns"
resolvedIPs = dnsClass.getHostEntry <hostname as string>
-- if hostname doesn't exist, it dies. d'oh. try/catch?
firstIP = resolvedIPs.addressList[1]
firstIPasString = firstIP.toString()
Edit: was reading old .NET documentation. .resolve has since been obsoleted, using .getHostEntry instead