From: Miguel <mt...@mt...> - 2003-05-02 08:55:07
|
> You can Expect-ize a Net::Telnet object by doing something like > > $Expect::Exp_Internal = 1; > > $t = new Net::Telnet(); > $t->open($host); > $t->login($name, $pass); > > $e = Expect->exp_init($t); > > print $e "ls\r"; > > $e->expect(60, $prompt); That looks great ... I'll give it a shot. A suggestion ... I think it may be helpful for others to put an example like this in the Expect man page. The doc says that exp_init takes a \*FILEHANDLE. And it looks like to me that Net::Telnet returns an object. Even now I don't understand why this works ... so on my own I would never have figured out this solution. Just my 2c :) > There's also a combo of the two, like you suggest, which is sort of a > best of both worlds approach where you let the protocol specific lib do > the dirty work, then use Expect afterwards. In this particular case, since I have already written everything using Expect, I think the right thing for me to do is only use Net::Telnet to manage the raw connection ... as your example above. In my quick read of Net::Telnet I saw that it generally uses the prompt-string to determine when commands are done. Cisco routers change the prompt string depending upon what kind of 'mode' you are in. That made me think that Expect was more flexible. Thanks to everyone for your help. Adios, Miguel |