aboutsummaryrefslogtreecommitdiff
path: root/tools/hex.sh
diff options
context:
space:
mode:
authorduke2906 <philipp.prangenberg@gmail.com>2016-09-26 15:09:20 +0200
committerGitHub <noreply@github.com>2016-09-26 15:09:20 +0200
commit960bf899414d89221e92138fdb98777c3f4f73ec (patch)
tree87f5fd96185aa5f2fff0f84e2e2fa8be379ee837 /tools/hex.sh
parent0d3c05a24992eeeba02032e474d3a9bbb3239f10 (diff)
parentaaec58aec04256845dc37afd713b488071b1406b (diff)
downloadtraccar-server-960bf899414d89221e92138fdb98777c3f4f73ec.tar.gz
traccar-server-960bf899414d89221e92138fdb98777c3f4f73ec.tar.bz2
traccar-server-960bf899414d89221e92138fdb98777c3f4f73ec.zip
Merge pull request #1 from tananaev/master
Update Changes, including version 3.7
Diffstat (limited to 'tools/hex.sh')
-rwxr-xr-xtools/hex.sh20
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 $?