Skip to content

Instantly share code, notes, and snippets.

@lunatilia
Last active September 15, 2021 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lunatilia/e99d304cb958e7686803 to your computer and use it in GitHub Desktop.
Save lunatilia/e99d304cb958e7686803 to your computer and use it in GitHub Desktop.
自ネットワーク内にいるRaspberry Piを探して、IPアドレスを表示するだけのお仕事をするスクリプト
#!/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