[NTLUG:Discuss] expect vs perl (was Telnet question)

rob apodaca robert.apodaca at attbi.com
Fri Aug 2 03:28:21 CDT 2002


On 01 Aug 2002 18:43:31 -0500
jm <jm5379 at sbcglobal.net> wrote:

> I'm trying to write an Expect script (my first, as I read Exploring
> Expect) to login to a server; I'm currently having a problem when I
> actually send login data to the server, either via Expect or
> interactively...
> 
> My .telnetrc has the following options defined for this specific system
> connection:
> 
> system.name.com
> 	unset echo
> 	mode character
> 
> When i type in my userid and hit <enter>, the cursor goes down to the
> next line, echos the userid again and simply waits; pressing <enter>
> drops the cursor down by 2 lines each time.
> 
> However...
> 
> If I enter ^] to get back to the telnet prompt, simply hit <enter>
> enough times to get back into the server, <enter> begins working exactly
> as it should.
> 
> What is the ^] sequence changing in the <enter> functionality (and why),
> or what option(s) do I need to add to .telnetrc to modify <enter>s
> default behavior?  Or as a last resort, how can I pass Control
> characters via Expect so they are recognizable by the receiving system
> rather than just being displayed on the screen as ^E or whatever?
> 
> Other users w/Hummingbird's telnet work fine so it should be just a
> simple setting.  The goal is to automate downloading configuration
> files, but the receiving systems apparently have severe time
> sensitivities so copy/paste blows up all too often to be feasible.
> 
> Any help over what should be a minor bump will be greatly appreciated.
> Joe

I'm not sure I can offer any help but, I am curious...what are the advantages to using Expect vs using Perl?

It appears that one could write a script very quickly...even automatically using autoexpect. However, from the man pages, there could be timing issues when using programs like telnet, ftp, ssh, etc because these types of programs might ignore keystrokes if they come before the prompt. So now one might have to insert a sleep into the Expect script. The timing could vary depending on server or network load. This all seems a little too 'loose' to me. It reminds me of my MS windows days using 'ezmacro'. Of course, I am not an authority on Expect because I've only looked at it and tried it a few times - I may be ignorant of some of its features.

Perl, on the other hand, or I should say Perl's modules, have taken care of the whole login interactive thing with services like telnet, ftp, ssh, etc. I guess the downside is that the learning curve for Perl is a bit steep. Also, to use these services, one needs the appropriate Perl Modules. If a user does not have root privileges to install the modules, then Expect may be the only option available.

I certainly don't want to start a war here. I am obviously biased towards Perl because that's what I know and use. I am just curious to know what others think about the subject.

Cheers,
rob




More information about the Discuss mailing list