Created
March 14, 2019 09:50
-
-
Save tksst/cb4290666337b4a30f311ee3d477800b to your computer and use it in GitHub Desktop.
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/bash | |
readonly MAC=01:23:45:67:89:AB | |
readonly BROADCAST=255.255.255.255 | |
readonly PORT=9 | |
# bashの組み込みechoに依存している | |
# zshでもそのまま動く(エスケープシーケンスがデフォルト有効で -e オプションは無視される) | |
# 注: | |
# ncコマンドでbroadcastする場合に | |
# -b オプションが必要な環境と不要な環境がある | |
# ポート番号は何でも良いが慣例で9番を使うことが多い | |
( | |
# FFを6回 | |
for a in {1..6}; do | |
echo -en '\xFF' | |
done | |
# MACアドレスのコロンを取り除きバイナリ化したものを16回 | |
for a in {1..16}; do | |
echo -en '\x'${MAC//:/\\x} | |
done | |
) | nc -w1 -u $BROADCAST $PORT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment