Skip to content

Instantly share code, notes, and snippets.

@for2ando
Last active October 16, 2022 13:49
Show Gist options
  • Save for2ando/e45f81e86f2b7183951f5902a69ad072 to your computer and use it in GitHub Desktop.
Save for2ando/e45f81e86f2b7183951f5902a69ad072 to your computer and use it in GitHub Desktop.
converting a NetBeui Name to the binded IP address on NetBeui on TCP/IP platform; for Cygwin.
#!/bin/bash
export LANG=ja_JP.UTF-8
pname=$(basename "$0")
usage="$pname NBName
$pname {-h|--help}
FEATURES
OPTIONS
"
errp=false
while true; do
case "$1" in
-h|--help) echo "$usage"; exit 0;;
-*) echo "$pname: $1: unknown option.">&2; errp=true; shift;;
*) break;;
esac
done
$errp && exit 1
test $# -le 0 && { echo "$usage"; exit 1; }
nbname="$1"
mac=$(nbtstat -a "$nbname" | iconv -f sjis -t utf-8 | sed -n '
/^.*MAC アドレス = \(..-..-..-..-..-..\).*$/s//\L\1/
T
#s/-/:/g
p
')
arp -a | iconv -f sjis -t utf-8 | awk '/'"$mac"'/ { print $1 }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment