Skip to content

Instantly share code, notes, and snippets.

@dmiyakawa
Created January 23, 2015 12:17
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 dmiyakawa/f30ad3324415dc79804b to your computer and use it in GitHub Desktop.
Save dmiyakawa/f30ad3324415dc79804b to your computer and use it in GitHub Desktop.
A script communicating with YK-KSM
!/bin/bash
host='localhost'
verbose=1
request_decrypt() {
otp=$1
qw_str=$(echo $otp | tr "axje.uidchtnmbrl'poygk,qf;" 'abcdefghijklmnopqrstuvwxyz')
url="http://${host}/wsapi/decrypt?otp=${qw_str}"
test $verbose -eq 1 && echo "url: ${url}"
curl ${url}
}
while getopts h:v OPT
do
case $OPT in
h)
host=$OPTARG
;;
v)
verbose=1
;;
\?)
exit
;;
esac
done
shift $((OPTIND - 1))
if [[ $# == 0 ]]; then
while true; do
read otp
if [[ -z "${otp}" ]]
then
break
fi
request_decrypt $otp
done
else
for otp in $@; do
request_decrypt $otp
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment