24 lines
480 B
Bash
24 lines
480 B
Bash
#!/bin/sh
|
|
HOST="${HOST:-localhost}"
|
|
PORT="${PORT:-1965}"
|
|
while getopts h:p: opt; do
|
|
case "$opt" in
|
|
h) HOST="$OPTARG";;
|
|
p) PORT="$OPTARG";;
|
|
*) usage;;
|
|
esac
|
|
done
|
|
shift $((OPTIND - 1))
|
|
for x in "$@"; do
|
|
fdwrap -f '3>stdin,stdin<stdout' -w \
|
|
"openssl s_client -quiet -connect $HOST:$PORT 2>/dev/null" \
|
|
awk 'BEGIN {
|
|
u = ARGV[1];
|
|
ARGV[1] = "-"
|
|
gsub(/'\''/, "&\\&&", u)
|
|
system("printf %s\\\\r\\\\n '\''" u "'\''>&3")
|
|
while (getline)
|
|
print
|
|
}' "$x"
|
|
done
|