Hi!
This is very popular question, I see
You can use following bash script as an example:
http://tiocu.svn.sourceforge.net/vie...il?revision=58. Function `wait4ack()' and lines below `echo connecting...' are of interest for you.
Shortly speaking we run telnet process in background and associate file descriptors 3 and 4 with its stdin and stdout using something like this:
Code:
mkfifo $FIFO
exec 4< <(telnet $SERVER 25 < $FIFO 2> /dev/null &)
exec 3>$FIFO
Now we can send commands to telnet through 3'rd fd and recieve responses through 4'th one:
Code:
echo $comm >&3
wait4ack "$optn" <&4
wait4ack() reads its stdin (i.e. 4'th file descriptor) until something like '+OK' in POP3 protocol or 250 in SMTP (see corresponding RFC document).
Hope, this helps.
firstfire == agre.
By the way, `telnet-ssl' can solve some security problems.