#!/bin/bash telnet ipaddr port & i=1 while [ "$i" -lt 3 ] do (( i += 1 )) sleep 10 done
Trying ipaddr... Connected to ipaddr. Escape character is '^]'. Connection closed by foreign host
fine, since bash scripts run in non interactive, so no stdin used, telnet close immediately.
however if I add tee to redirect the result, like
telnet ipaddr port | tee -a out.txt &
the telnet service could run and get output. but what is the difference tee made? i expect the telnet will terminate immediately as well.