>How I can redirect the stdin and stdout to a TCP connection?
>The reason I asked this question is because I want to use a
>regular shell application thru telnet. For example, if somebody
>types telnet xxx.xxx.xxx.com 12345 I want my shell/C program
>to attend the socket, but at the same time if I am at the
>shell prompt I would like to execute the same program using
>the standard IO.
If you have root access, use inetd (see man inetd). Otherwise, see the inetd
source or something... Inetd does just that before executing any daemon.
An example from the /etc/inetd.conf I have (not on spider.compart.fi):
systat stream tcp nowait guest /usr/sbin/tcpd /bin/ps -auwwx
netstat stream tcp nowait guest /usr/sbin/tcpd /bin/netstat -tu
And those are the standard ps and netstat... Tcpd is from tcp_wrapper, you
don't need it for this (but it's otherwise a good thing to have).
--
"The world is indeed full of peril, and in it there are many dark places;
but still there is much that is fair, and though in all lands love is now
mingled with grief, it grows perhaps the greater." - J.R.R. Tolkien