Hi!

About two years ago I wrote some Perl program using Expect to automatically log in via SSH; it was based on v1.21.

Today I ran the program again (now at v1.32), and the program does not work as expected:

I'm waiting for a password prompt, then the user should type the password. The regex matches, but the after-match string (that should be empty) has unexpected contents.

Here is the essential part of the debug output:

spawn id(3): Does `*************************************************** +***************************\r\n* This login banner can be configured +to adhere to your corporate security *\r\n* policies. + *\r\n* + *\r\ +n* Due to security concerns, default users will be prompted to change + default *\r\n* passwords upon login. To retain the default password, + re-enter it at the *\r\n* Password: and Confirm: prompts. + *\r\n* + *\r\n**************** +**************************************************************\r\n\r\ +nPassword: ' match: pattern #1: -re `^Password: $'? YES!! Before match string: `******************************************** +**********************************\r\n* This login banner can be conf +igured to adhere to your corporate security *\r\n* policies. + *\r\n* + + *\r\n* Due to security concerns, default users will be prompted to + change default *\r\n* passwords upon login. To retain the default pa +ssword, re-enter it at the *\r\n* ' Match string: `Password: ' After match string: `and Confirm: prompts. + *\r\n* + *\r\n******************************* +***********************************************\r\n\r\nPassword: ' Matchlist: ()

As you can see "Password:" is not matched at the beginning of the line as expected (despite of saying differently); at least the after string behaves as if the "Password:" was matched in the middle of a line.

To me it seems the version of Expect.pm is broken; see also https://bugzilla.opensuse.org/show_bug.cgi?id=976535


In reply to Unexpected after-match with Expect by CharLee

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.