#!/bin/bash QUERY_STRING=$(echo "${QUERY_STRING}" | sed 's/;//g') function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } if [ "${QUERY_STRING}" ]; then export IFS="&" for cmd in ${QUERY_STRING}; do if [ "$(echo $cmd | grep '=')" ]; then key=$(echo $cmd | awk -F '=' '{print $1}') value=$(echo $cmd | awk -F '=' '{print $2}') eval $key=$value fi done fi x=$(urldecode "$atcmd") MYATCMD=$(printf '%b\n' "${atcmd//%/\\x}") if [ -n "${MYATCMD}" ]; then # Capture the response and remove ANSI color codes using awk runcmd=$(atcmd '$x' | awk '{ gsub(/\x1B\[[0-9;]*[mG]/, "") }1') fi echo "Content-type: text/plain" echo $x echo "" echo "$runcmd"