Skip to content

Instantly share code, notes, and snippets.

@TAGC
Created July 17, 2017 08:06
Show Gist options
  • Save TAGC/c84f9c63e6e7e2fb8a954fdedefb2def to your computer and use it in GitHub Desktop.
Save TAGC/c84f9c63e6e7e2fb8a954fdedefb2def to your computer and use it in GitHub Desktop.
Locates the IP address of a Raspberry Pi on a network
@Echo off
REM Locates the (dynamic) IP Address of a Raspberry Pi on a network
REM Note that with Git Bash, it's possible to invoke batch scripts
REM This lets you do something like this:
REM $ ssh your-login@$(./find-pi.bat)
Set "PiMac=b8-27-eb"
Set "Range=172.16.1"
Set "Ping=ping.exe -n 1 -l 0 -f -i 2 -w 1 -4"
Set "FindPi=arp -a^|findstr /i %PiMac%"
For /L %%A in (1,1,254) do Start /HIGH /B %Ping% %Range%.%%A >nul 2>&1
For /F "tokens=*" %%A in (' %FindPi% ') do set Result="%%A"
For /F "tokens=1 delims= " %%A in (%Result%) do echo %%A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment