1

Parameretrize file descriptor number to open a tcp socket in shell script

view story
linux-howto

http://unix.stackexchange.com – I'm tried to parameretrize in a variable the file descriptor number to open a tcp socket using exec command but it failed. Only work correctly when file descriptor number is a constant. In the next example code only success the first retry (RC=0). Code: echo -e "\nRetry 1: " socket="/dev/tcp/$ip/$port" exec 3<>$socket echo "RC: $?" echo -e "\nRetry 2: " descriptor=3 socket="/dev/tcp/$ip/$port" exec $descriptor<>$socket echo "RC: $?" echo -e "\nRetry 3: " descriptor="3" socket="/dev/tcp/$ip/$port" exec $descriptor<>$socket echo "RC: $?" echo -e "\nRetry 4: " descriptor (HowTos)