TCP connection, bash only

< and > are usually used to redirect IOs. What does it mean there? Is it usable in another context? How?

It’s the same – input and output is redirected to fd 5.

Why does it work, while /dev/tcp doesn’t exists?

It’s a special file: If host is a valid hostname or Internet address, and port is an integer port number or service name, bash attempts to open a TCP connection to the corresponding socket.

Why 5? Can it be another number? What are the values allowed?

Yes, it can be any value, but you need to ensure you don’t use an fd already in use.

Why is exec necessary? (given nothing is actually executed)

exec means the redirection happens in the current shell, not within a subshell.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)