From: Austin S. <te...@of...> - 2003-10-08 04:32:29
|
On Wed, Oct 08, 2003 at 05:17:47PM +1300, Andrew Cutler wrote: > Hi, > > What about if you want the last object to be a separate expect instance? > I have a situation where I need to: > You could if you wanted turn/copy it into a new object, but that probably won't give you the functionality you're looking for. > telnet to a cisco router and configure an interface to provide > connectivity to another device. > > telnet from the router to the device and login. > interact. > logout from the device and fallback to the cisco, > > deconfigure the interface and shut it down. > logoff. > > My problem is the moron users who won't read the initial text that tells > them to hit control X to exit (interact escape sequence). Most of them > are logging out cleanly from the device and if this was a separate > expect object, control would return to the program and I could clean up > the router. So don't call interact. read from the user and write to the router, and vice versa. > > The man page says the escape sequence will not work with multiple > characters so I can't use "exit" etc. This is true, see above comment. Also you can still look for strings like 'connection closed by foreign host', etc. > > Can I expect from an instance while it's in interact mode? I could look > for the logout command or watch for when the prompt changes back to the > original router. > Yeah, that's what you do. You don't need to do interact to accomplish this. Also, you can use the '-i' flag to expect() to wait for input from both the device and the user. Well, that's how I would do it anyway. Austin |