Currently it is just regular old read/regex code, but I do have plans to add the expect features once I get this part working.... and I do have ssh keys set up. I'm not passing it a password when I create the object (mostly because this is running under an account where not everyone should know the password).

It always happens on server2, but server2 is no different than server1. They have the same OS version, and the ID is the same for both, (automounted home directory) so it's using the same profile and env variables and all that.

It's not too much trouble to regex out the prompt, I can do that easily enough, I was just hoping there was some cool Expect feature that would do that for me, or maybe I was doing something wrong.

One other thing I'm running into, however, is that when I come across a server that my key doesn't work on (ie one that does not use autofs for home directories) I get a password prompt. I'd like to be able to just detect these, add it to my no-connect list with a comment, so I can get a list of servers that need a manual key set up later, but instead it's trying to execute the commands, (in essence pressing enter 3 times) then getting the permission denied keyboard/interactive message, then the SSH connection dies, so I receive the SSHProcessError message.

It's obvious to me I need to use more of the expect features, as that would (probably) easily fix my most recent problem, but it does lead me to another question:

If I create an ssh connection, then issue a waitfor (or expect) statement, what keeps the prompt from displaying too fast for the waitfor, so then I'm waiting for nothing until the timeout. For example:

1. ssh serverX
2. (serverX asks for a password - Password:)
3. waitfor "Ppassword:"

What keeps that from happening, or does it just queue up in STDIN?

Thanks!

In reply to Re^4: Net::SSH::Expect output by sierpinski
in thread Net::SSH::Expect output by sierpinski

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.