I'm trying to write a bash function to test SSH connections :
$ echo $0
-bash
$ time timeout 20s cat < /dev/tcp/$server/ssh;test $? = 124 && echo "WARNING: Could not connect to $server on ssh."
-bash: connect: Connection timed out
-bash: /dev/tcp/X.Y.Z.T/ssh: Connection timed out
real 1m3.000s
user 0m0.000s
sys 0m0.000s
WARNING: Could not connect to X.Y.Z.T on ssh.
How can I make this timeout command work ?
timeoutis not buit in to bash. This means the redirection is set up beforetimeouteven executes.set -vx; timeout 1 echo main 11< <(echo 1 >/dev/tty) 12< <(echo 2 >/dev/tty) </dev/tcp/$server/22 13< <(echo 3 >/dev/tty). Note that first and last echo don't happen because tcp redirect caused termination