I've never used Expect.pm before and it's not clear from your description, but I think this may be more complex than it appears.

I suppose that from the snippet you've posted that it is invoked on a 'nix system. If so, I guess that you're running it via a PC terminal session of some sort (telnet or Putty/other SSH type connection). If so, the program will expect keyboard codes that are agreed upon by both the 'nix system and the PC emulation software. The 'nix terminal type is probably the same as that defined for the account you're running it from. You'll need to lookup and use the escape sequences for that emulation and send them to Expect (hint: if you specify simple emulations, your control sequences can be simplified as well). You can try the methods explained by the other monks here, use the suggestions in Expect.pod:

Q: How do I send control characters to a process? A: You can send any characters to a process with the print command. To represent a control character in Perl, use \c followed by the lette +r. For example, control-G can be represented with "\cG" . Note that this will not work if you single-quote your string. So, to send control-C to a process in $exp, do: print $exp "\cC"; Or, if you prefer: $exp->send("\cC");
or build strings using the chr(dec) function:
$vt220_pgup = chr(27) . chr(91) . chr(51) . chr(126); print $exp $vt220_pgup
I could be totally off base on this, so please let me know if this is the case. I've made a lot of suppositions here but perhaps, if nothing else, it may give you a place to start.

--Jim


In reply to Re: IBM scan codes (pgup, pgdn, arrow keys) by jlongino
in thread IBM scan codes (pgup, pgdn, arrow keys) 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.