From: Austin S. <te...@of...> - 2003-05-01 22:48:28
|
On Thu, May 01, 2003 at 11:45:25PM +0200, Miguel wrote: > > > Hmm, well I can confirm from my experience that solaris ptys are > > somewhat broken in many regards. But this doesn't help you. :-) > > > > What comes to mind is to circumvent ptys completely. Have you considered > > using Net::Telnet instead of spawning a telnet program? > Roland, > > That sounds like a great idea. > > I just took a look at the Expect & Net::Telnet man pages ... and frankly > it isn't yet clear to me how to hook to two together. That is ... what > method(s) do I use instead of $exp->spawn('telnet foo') > > Any pointers would be appreciated 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); though you may want to just look at the Net::Telnet native routines such as 'cmd' and the like. There are basically two schools of thought. One is "use Net::Telnet because it's the tool made for the protocol" (telnet in this case). It will be more portable, and support protocol-specific functionality better as a general rule. The other is "use Expect because you are lazy". Handy if you are already familiar with it and don't need portability. The API is always the same. Both schools of thought have their advantages, well at least IMO. 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. Austin |