Skip to content

Instantly share code, notes, and snippets.

@melissaboiko
Created September 29, 2010 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melissaboiko/602883 to your computer and use it in GitHub Desktop.
Save melissaboiko/602883 to your computer and use it in GitHub Desktop.
#!/bin/bash
# a telnet-like command to debug text protocols over SSL (https, smtps...).
# usage:
# telnets example.com https
# telnets example.com:https
# telnets https://example.com
if echo "$1" | grep -q "^[a-z]*://"; then
host="$(echo $1 | sed -e "s,^\([a-z]*\)://\(.*\),\2,")"
port="$(echo $1 | sed -e "s,^\([a-z]*\)://\(.*\),\1,")"
elif echo "$1" | grep -q :; then
host="$(echo $1 | sed -e "s,\([^:]*\):\(.*\),\1,")"
port="$(echo $1 | sed -e "s,\([^:]*\):\(.*\),\2,")"
else
host="$1"
port="$2"
fi
openssl s_client -quiet -connect "$host":"$port"
function telnets()
{
# a telnet-like command to debug text protocols over SSL (https, smtps...).
# implemented as function cause I put it in my .bashrc .
# usage:
# telnets example.com https
# telnets example.com:https
# telnets https://example.com
local host port
if echo "$1" | grep -q "^[a-z]*://"; then
host="$(echo $1 | sed -e "s,^\([a-z]*\)://\(.*\),\2,")"
port="$(echo $1 | sed -e "s,^\([a-z]*\)://\(.*\),\1,")"
elif echo "$1" | grep -q :; then
host="$(echo $1 | sed -e "s,\([^:]*\):\(.*\),\1,")"
port="$(echo $1 | sed -e "s,\([^:]*\):\(.*\),\2,")"
else
host="$1"
port="$2"
fi
openssl s_client -quiet -connect "$host":"$port"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment