TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:2010] automatic telnet etc



-> Thanks. Expect is definetly the way to go. I've got one problem though,
-> when the finish the expect script (i.e. I have logged in) except closes
-> all spawned processes, which means I lose my connection to the server.
-> I've tried ending the expect script with "close -noexit" but doesn't work.
-> Maybe I need to run the expect script after starting the telnet session,
-> but I don't know how to do that. (neither login&;telnet ip nor 
-> telnet&;login work)

Try inserting the 'interact' command at the end of your script.
According to the man page, this "gives control of the current process
to the user, so that keystrokes are sent to the current process, and
the stdout and stderr of the current process are returned."

Then, I believe, when you terminate the process (your telnet session),
the interact command will terminate and so will the expect script.
There are fancier ways to use interact, but this is probably all
you'll need.

For more information and ways to use expect in unexpected ways (pun
intended), the O'Reilly book is a good source.

Hope this helps,

Eric