Page 1 of 1
Identify the pi by hostname
Posted: Fri Jan 06, 2017 6:58 pm
by gproduct
Hello!
I'm working on a project for which I need to know the ip of a pi with a hostname 'test'.
How do I achieve this?
Should I go the long route and ping every device on the network, but how do I know if the hostname is 'test'?
Thanks!
Re: Identify the pi by hostname
Posted: Fri Jan 06, 2017 7:05 pm
by W. H. Heydt
Current versions of Raspbian broadcast to the LAN. You can connect to one by connecting to "<hostname>.local" providing the source system has the feature enabled. In your case, "test.local".
Re: Identify the pi by hostname
Posted: Fri Jan 06, 2017 7:06 pm
by JumpZero
Hi!
If the pi named test is running stock Raspbian, then the avahi daemon is running on it.
So from another machine on the network you can ping the pi with this command
Note that this machine must also run avahi/mDNS/Bonjour. This will be the case with a Mac or a recent GNU/Linux but not with Windows (however it seems possible to add this service to Windows as well)
--
Jmp0
Edit: I was 1mn slower than.. W. H. Heydt

Re: Identify the pi by hostname
Posted: Fri Jan 06, 2017 7:07 pm
by gproduct
Okay, how do I achieve that with python scripts?
Re: Identify the pi by hostname
Posted: Fri Jan 06, 2017 7:10 pm
by gproduct
Yes that works!!!! Thank you very much!
I will transfer the ping to python scripts and ill get what I need.
Again thank you very much!
Re: Identify the pi by hostname
Posted: Fri Jan 06, 2017 7:12 pm
by JumpZero