Page 1 of 1
Finding a PCs IP address using computer name but using a mac
Posted: Thu Jul 09, 2015 8:34 pm
by Da_Elf
ok so im using the below code on my PC laptop to get the IP address of another PC on the network so that i can log into its database
This laptop is linked wirelessly (if thats a word) and it can find and contact the computer with the database
I exported the program for mac and tried it on a mac mini with wifi we have here however it didnt work trying to convert the PCs name to IP
Code: Select all
global gConnectionIP
on ContactServer
put the hostNameToAddress of (the text of fld "DBaseComputer") into testserver
if testserver is empty then
answer "Can not find the server computer"
else
put testserver &":3306" into gConnectionIP
answer "Found Server"
end if
end ContactServer
Re: Finding a PCs IP address using computer name but using a
Posted: Thu Jul 09, 2015 10:03 pm
by ghettocottage
can you assign the database computer a static ip via your router? Might be easier than trying to script all this.
if not, can you ping the computer name from a cmd terminal and get a response?
just: ping testserver
Re: Finding a PCs IP address using computer name but using a
Posted: Fri Jul 10, 2015 1:40 am
by sturgis
if I recall correctly, for this to work on a mac you have to change some netbios stuff in the settings. (since windows networks don't use a standard dns type of server thing)
Basically, you'd go into network settings, advanced, go to the WINS tab and set things up so that you're in the right workgroup, and if you have a wins server on the network, you can add its IP there also. It MIGHT be enough to just set up the workgroup and wait. Again, if I recall correctly, machines broadcast their netbios names and hopefully the mac will pick em up. Its been a LONG time since I've done any of this though, so google is your friend.
Another option? Run your own dns and dhcp to assign names and addresses, and have all your machines point to the internal dns.
The final option as mentioned is just hard code your IP's and use those to reference machines.
Just did another search.. On mavericks, it looks like you might be able to use shell
get shell("smbutil lookup computername")
If this works, its probably the easiest answer.
Re: Finding a PCs IP address using computer name but using a
Posted: Sat Jul 11, 2015 4:53 pm
by Da_Elf
the reason im using hostNameToAddress is because i dont want to have to hardcode the ip address of that system. the correct workgroup is setup on the mac but it still cant find the pc by the pcs computer name
Re: Finding a PCs IP address using computer name but using a
Posted: Sat Jul 11, 2015 5:05 pm
by sturgis
Did you try get shell("smbutil lookup computername")
?
Don't know if it will work, but curious to know if it does.
Re: Finding a PCs IP address using computer name but using a
Posted: Sat Jul 11, 2015 10:08 pm
by Da_Elf
yup. it worked. i had to tell it to check OS and see if it was windows or mac then to tell it which way to do the lookup. the replay i had to do some work to get just the IP from it since it spouts out a bunch of text more than the ip
Re: Finding a PCs IP address using computer name but using a
Posted: Sat Jul 11, 2015 10:20 pm
by SparkOut
tracert should work on both windows and Mac OS X, there may be a little variance in response but the first thing that looks like an ip address should be the destination.
Re: Finding a PCs IP address using computer name but using a
Posted: Sat Jul 11, 2015 10:23 pm
by sturgis
The purpose is to resolve the local ip of a system on the network. In this case using the netbios name of a windows machine, and getting its ip from a mac. Will tracert do this? I'll have to add it to my toolbox if so!
Re: Finding a PCs IP address using computer name but using a
Posted: Sat Jul 11, 2015 10:55 pm
by SparkOut
Yes, it should do, I believe. It definitely will on windows. Pretty sure the responses are very similar on OSx.
tracert hostname
and you will see the first line such as
tracing route to hostname (192.168.0.55) blah blah
and then a series of hops indicating the route via each ip of the nodes being traversed. Within a local network there will likely be only one hop, directly to the destination.
Re: Finding a PCs IP address using computer name but using a
Posted: Sun Jul 12, 2015 12:26 am
by Da_Elf
this is what the tracert method gave me on the PC
Tracing route to CasparMain-PC [192.168.99.101]
over a maximum of 30 hops:
1 1 ms 1 ms 1 ms CasparMain-PC [192.168.99.101]
Trace complete.
on the mac though i get
/bin/sh: line 1: tracert: command not found
Re: Finding a PCs IP address using computer name but using a
Posted: Sun Jul 12, 2015 12:27 am
by sturgis
on a mac its spelled out in full: traceroute
So you'll still have to separate the 2 shell calls.
Re: Finding a PCs IP address using computer name but using a
Posted: Sun Jul 12, 2015 12:55 am
by Da_Elf
ok im not sure how to use it this time i get :
traceroute:unknown host CASPARMAIN-PC
Re: Finding a PCs IP address using computer name but using a
Posted: Sun Jul 12, 2015 12:59 am
by sturgis
Ah k. Thats the answer then. If you don't have your mac set up to do netbios name resolution, it won't work. Looks like you'll still want to stick with the other method unless you can figure out how to get resolution working. (Its been too long, i'm not sure how) the smbutil method should work fine though.
Re: Finding a PCs IP address using computer name but using a
Posted: Sun Jul 12, 2015 1:22 am
by Da_Elf
the smbutil one is fine for me. as long as it works is all i care about
Re: Finding a PCs IP address using computer name but using a
Posted: Sun Jul 12, 2015 8:29 am
by SparkOut
Yes, if tracert and traceroute mean you need to use different calls anyway, just use what you know will work.