laconia/laconia

34 lines
679 B
Plaintext
Raw Normal View History

2021-07-05 17:01:04 +00:00
#!/bin/sh
PROGNAME=${0##*/}
VERSION="0.0.1"
2021-07-06 08:11:28 +00:00
proto="$(echo $1 | grep :// | sed -e's,^\(.*://\).*,\1,g')"
url=$(echo $1 | sed -e 's,$proto,,g')
host=$(echo "$url" | sed -e 's|^[^/]*//||' -e 's|/.*$||')
path="$(echo $url | grep / | cut -d/ -f2-)"
port=300
2021-07-05 17:01:04 +00:00
error_exit() {
printf "%s: %s\n" "$PROGNAME" "${1:-"Unknown Error"}" >&2
exit 1
}
usage() {
2021-07-06 08:11:28 +00:00
printf "usage: %s [OPTIONS] URI [ARGS]\n" "$PROGNAME"
2021-07-05 17:01:04 +00:00
printf "Simple client for spartan protocol\n"
}
case $1 in
-h | --help)
usage; exit ;;
2021-07-06 08:11:28 +00:00
-p | --port)
export PORT=$3 ;;
2021-07-05 17:01:04 +00:00
-* | --*)
usage; error_exit "unknown option $1" ;;
*)
2021-07-06 08:11:28 +00:00
echo $proto $host $path $port
printf "$host /$path 0\r\n" | nc $host $port
2021-07-05 17:01:04 +00:00
;;
esac