diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-09-22 10:57:16 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-22 10:57:16 +1200 |
commit | 25ca1079714b5c5efc8e32dc4e8a11b7ef5b0c6b (patch) | |
tree | a8c1c08b0e74a09d70422203689c0fe9ca018a15 | |
parent | aff998db51d9fa4b66018139a4c5375a42ff42e8 (diff) | |
parent | ad2f5a00a4a27f085f470d3d86c52de01ff2c766 (diff) | |
download | trackermap-server-25ca1079714b5c5efc8e32dc4e8a11b7ef5b0c6b.tar.gz trackermap-server-25ca1079714b5c5efc8e32dc4e8a11b7ef5b0c6b.tar.bz2 trackermap-server-25ca1079714b5c5efc8e32dc4e8a11b7ef5b0c6b.zip |
Merge pull request #2355 from dcbastos/hex.sh
Adds support for specifying a host
-rwxr-xr-x | tools/hex.sh | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/hex.sh b/tools/hex.sh index cfae14bb6..78cd8fa38 100755 --- a/tools/hex.sh +++ b/tools/hex.sh @@ -10,26 +10,34 @@ if [ $# -lt 2 ] then - echo "USAGE: $0 <port> <hex>" + echo "USAGE: $0 <host> <port> <hex>" + echo "If only <port> and <hex> are present, <host> defaults to localhost." exit 1 fi +host="$1"; port="$2"; hex="$3"; + +if [ $# -eq 2 ] +then + host="localhost"; port="$1"; hex="$2"; +fi + send_hex_udp () { - echo $2 | xxd -r -p | nc -u -w 0 localhost $1 + echo "$hex" | xxd -r -p | nc -u -w 0 "$host" "$port" } send_hex_tcp () { - echo $2 | xxd -r -p | nc localhost $1 + echo "$hex" | xxd -r -p | nc "$host" "$port" } send_text_udp () { - echo -n -e $2 | nc -u -w 0 localhost $1 + echo -n -e "$hex" | nc -u -w 0 "$host" "$port" } send_text_tcp () { - echo -n -e $2 | nc localhost $1 + echo -n -e "$hex" | nc "$host" "$port" } -send_hex_tcp $1 $2 +send_hex_tcp "$host" "$port" "$hex" exit $? |