expect: redirect telnet to file

I've got some expect/tcl scripts.
Now i want to add a function that allows to open a telnet connection and redirect the output to a logfile.

On the shell/terminal i tried something like:
'telnet 192.168.123.123 12121 > /home/user/logging/log-telnet.log'
and the telnet is redirected into the file. But the process could only be stopped by kill PID.

So now i want a working code that creats a redirection to a file using expect.
So that i can use it there. But the process should stop at least when the expect script ends.

Is there anyone how knows expect ?

I am not an expert in "expect" but there is an excellent application that can help you create your "expect" script.

Check "autoexpect".

This link may help you: autoexpect(1) - Linux man page

Thanks for the hint.
My first test looks a bit ... confused. But i ll give it another try :wink:

If anyone has another idea...