A note from the father of Perl Expect, Roland Giersig (roland@giersig.org). Some guy was asking about a Solaris peculiarity using telnet under expect, and Roland replied. > What comes to mind is to circumvent ptys completely. Have you considered > using Net::Telnet instead of spawning a telnet program? The guy then answered, > 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 To which Roland replied, > 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.