#!/bin/bash host="ie-entwicklung@$1" tunnel() { name=$1 ip=$2 rPort=$3 lPort=$4 echo -n "$name @ $ip mapped to localhost:$lPort " ssh -nNTL "$lPort:$ip:$rPort" "$host" 2> /dev/null & until nc -vz 127.0.0.1 $lPort 2> /dev/null do echo -n . sleep 0.5 done echo "ok" } echo "" tunnel "Trumpf Inverter (http) " 10.0.2.1 80 8001 tunnel "Trumpf DCDC (http) " 10.0.3.1 80 8002 tunnel "Ext Emu Meter (http) " 10.0.4.1 80 8003 tunnel "Int Emu Meter (http) " 10.0.4.2 80 8004 tunnel "AMPT (http) " 10.0.5.1 8080 8005 echo echo "press any key to close the tunnels ..." read -r -n 1 -s kill $(jobs -p) echo "done"