#!/bin/sh set -eu # default options host="127.0.0.1" port=1340 retry_timeout=10 usage() { cat <&2; exit 1; fi eval set -- "$TEMP" while true; do case "$1" in -h|--help) usage; exit 0;; -H|--host) host="$2"; shift 2;; -p|--port) port="$2"; shift 2;; --) shift; break;; *) echo "Arguments parsing error" >&2; exit 1;; esac done if test $# -lt 1; then echo "You must put a command to call" >&2; exit 1 fi set +e while true; do while ! nc -q0 "$host" "$port"; do sleep $retry_timeout; done | "$@" sleep 1 done