how do i reduce timeout on unix telnet on connection
问题 I have a unix shell script which test ftp ports of multiple hosts listed in a file. for i in `cat ftp-hosts.txt` do echo "QUIT" | telnet $i 21 done In general this scripts works, however if i encounter a host which does not connect, i.e telnet is "Trying...", how can I reduce this wait time so it can test the next host ? 回答1: Have you tried using netcat ( nc ) instead of telnet? It has more flexibility, including being able to set the timeout: echo 'QUIT' | nc -w SECONDS YOUR_HOST PORT # e.g.