#!/bin/bash

# VERSION=2
# CHANGES="Close connection after timeout."

ISGW_TIMEOUT=5
ISGW_PORT=54322

if [ -z "${1}" ]; then
	echo -e "Usage:   ${0} [COMMAND]\n"
	exit 1
fi

isgw_ans_full=$(echo -ne "${1};q\r\n" | /bin/nc -q ${ISGW_TIMEOUT} localhost ${ISGW_PORT})
isgw_ans_stripped=$(expr match "${isgw_ans_full}" ".*disconnect client\(.*\)Closing terminal")

echo -e "${isgw_ans_stripped}"
