I feel a bit dumb asking this, but here it goes.
I'm trying to implement a very simple ftp client in bash, for testing purposes, and thought I could use a clean approach at reading/writing from/to the socket using exec
and process substitution, as follows.
exec 3<> /dev/tcp/$host/$port
exec 4< <(dos2unix <&3)
exec 5> >(unix2dos >&3)
I would then read from fd 4
and write to fd 5
in order to send commands and receive responses.
Alas, whilst writing works like a charm, reading doesn't: dos2unix
just gets stuck as if waiting for input that never arrives. Using any other command in place of dos2unix
shows the same behavior, but using a real character device in place of /dev/tcp
, say /dev/urandom
, works as expected.
Am I doing something fundamentally wrong, or what is the problem?