for each in host1 host2 host3; do echo -e "\n$each\n-------------------------------"; ssh -q $each "sleep 1 | telnet 192.168.1.1 55431; sleep1 | telnet 192.168.1.2 55431; sleep 1 | telnet 192.168.1.1 55432; sleep1 | telnet 192.168.1.2 55432; exit;"; done;