Depending on what you are doing at the remote site, Expect may not be the best solution. Instead of using telnet/Expect, why not use ssh?

Rather than having to handle login character by character yourself, you simply invoke ssh using system(), specifying the account and machine names. Assuming you are connecting to the same machines all the time, you can set up configuration files so that the remote sites know which sites will connect to them. You have to follow some slightly complicated procedure, but the instructions are clear enough.

The result is a configuration where you do not have to specify a password, hence the password does not appear in any script nor in any config file. Since login is based on encryption keys, unauthorized sites are totally blocked. And your code becomes a lot simpler.

If you are connecting to different machines each time, then you will have to provide a password, somehow. But you still gain benefits, your connection will be encrypted, the password will be passed encrypted, not clear-text, to the remote machine.

--
TTTATCGGTCGTTATATAGATGTTTGCA


In reply to Re: User interaction mid script again by TomDLux
in thread User interaction mid script again by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.