Is it possible to listen to a TCP port only with a shell, with no additional tools? [closed]
Solution 1:
No, a basic Bourne/POSIX shell (/bin/sh
) cannot be expected to include any built-in facilities for TCP connections. See comparision of command shells in Wikipedia.
The bash
shell would have TCP and UDP client capabilities with a special handling of certain filenames: for example, using /dev/tcp/<hostname>/<port>
in input/output redirection on a command line causes bash
connect to the specified host and port and use the connection as input source or output destination. But bash
cannot listen on a port: it cannot act as a TCP server.
The zsh
shell would have both client and server functionality, but only using TCP. On the other hand, zsh
is not a simple shell: it's probably the most feature-rich (and so the largest) of the common unix-style shells as far as I know. Finding zsh
on a small embedded system would be rather unlikely.
While I was writing my answer, you indicated in the comments that you found a "lighthttpd
" binary. Is it perhaps this? https://www.lighttpd.net/