Last active
September 15, 2021 12:53
-
-
Save lunatilia/e99d304cb958e7686803 to your computer and use it in GitHub Desktop.
自ネットワーク内にいるRaspberry Piを探して、IPアドレスを表示するだけのお仕事をするスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#----- chenge parameters your environment -----# | |
# examples: | |
# Your PC's IP address: 192.168.0.100 | |
# Search scope: 192.168.0.1 - 192.168.0.254 | |
# | |
# OWN_NETWORK="192.168.0" | |
# SRCH_START=1 | |
# SRCH_END=254 | |
OWN_NETWORK="192.168.0" | |
SRCH_START=1 | |
SRCH_END=254 | |
#----------------------------------------------# | |
for OCT4 in `seq ${SRCH_START} ${SRCH_END}` | |
do | |
ping ${OWN_NETWORK}.${OCT4} -c 1 > /dev/null 2>&1 & | |
done | |
PING_REMAIN=1 | |
echo -n "Finding Raspberry Pi " | |
while [ ${PING_REMAIN} -eq 1 ]; do | |
echo -n "." | |
ps -ef | grep [p]ing > /dev/null 2>&1 | |
if [ $? -ne 1 ]; then | |
PING_REMAIN=1 | |
sleep 1 | |
else | |
PING_REMAIN=0 | |
echo | |
fi | |
done | |
arp -n | grep -e b8:27:eb: -e dc:a6:32: -e e4:5f:01 | sort -k 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment