Skip to content

Instantly share code, notes, and snippets.

@chiefy
Created May 11, 2017 00:31
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 chiefy/e8450771c33b059dfbbfc9846e29369b to your computer and use it in GitHub Desktop.
Save chiefy/e8450771c33b059dfbbfc9846e29369b to your computer and use it in GitHub Desktop.
testing cmd.io stuff
#!/bin/bash
user=${1:-chiefy}
hostname=localhost
port=2223
ssh="ssh ${user}@${hostname} -p ${port}"
cmd_name=tester
test_cmd=$(cat <<'EOD'
#!cmd.io alpine bash
#!/bin/bash
echo
env
echo
i=1
echo "args:"; for arg in $@; do printf "${i}-${arg} "; i=$((i+1)); done; echo
EOD
)
${ssh} :rm ${cmd_name}
echo "${test_cmd}"|${ssh} :create ${cmd_name}
token=$(${ssh} :tokens new ${cmd_name})
${ssh} :access ${cmd_name} grant ${token}
echo
echo "no args -----------------------------------"
curl -sS "http://${token}@localhost:8080/run/${user}/${cmd_name}"
echo "-------------------------------------------"
echo
echo "args query --------------------------------"
curl -sS "http://${token}@localhost:8080/run/${user}/${cmd_name}?args=hi%20how+yes%20asdf+some+other%20ones"
echo "-------------------------------------------"
echo
echo "non-args query ----------------------------"
curl -sS "http://${token}@localhost:8080/run/${user}/${cmd_name}?val=true&something=else&whatever=false+maybe"
echo "-------------------------------------------"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment