forked from mozilla/autophone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ap
executable file
·47 lines (42 loc) · 915 Bytes
/
ap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
options="s:p:h"
function usage()
{
cat<<EOF
usage: $(basename $0) [-s server] [-p port] [command]
optional arguments:
-h
show this help message
-s server
autophone server to contact. (default: localhost)
-p port
autophone server port to contact (default: 28001)
command
command. (default: autophone-status)
Use autophone-help to get help on autophone commands.
EOF
exit 0
}
port=28001
server=127.0.0.1
let nshift=0
while getopts $options optname; do
case $optname in
h) usage;;
s) server="$OPTARG"
let nshift=nshift+2
;;
p) port="$OPTARG"
let nshift=nshift+2
;;
esac
done
shift $nshift
if [[ -z "$1" ]]; then
cmd="autophone-status"
elif [[ -z "$server" || -z "$port" ]]; then
usage
else
cmd="$@"
fi
echo $cmd | nc $server $port