Hello Monks,

I am using the Expect module to connect to a list of servers to gather information (output of metastat -p, dumpadm, etc) for a report. It seems to be working fine, however occasionally (not even for each server or command) I will get a prompt embedded in my output. For example:
server1: d102 -m d4 1 - Not Mirrored server1: d101 -m d2 1 - Not Mirrored server1: d100 -m d0 1 - Not Mirrored server1: d104 -m d8 1 - Not Mirrored server2: server2:user> d104 -m d8 1 - Not Mirrored server2: d103 -m d6 1 - Not Mirrored server2: d102 -m d4 1 - Not Mirrored server2: d101 -m d2 1 - Not Mirrored server2: d100 -m d0 1 - Not Mirrored server3: server3:user> metastat: server3: there are no existing datab +ases - Not Mirrored server3: - Not Mirrored

I add the ' - Not Mirrored' part, but for the commands in there, the server2:user> prompt gets stuck in there. I understand why it occurs when the command fails (ie for the one on server3 where there are no existing databases -- that is the output of the command) but not for the one for server2 where the command returns the same output as it did for server1. Hopefully my question makes sense. I'm relatively new to the Expect module, so I'm still getting a feel for it.
If anyone wouldn't mind enlightening me as to why the prompt only sometimes gets dumped to the output, and how to prevent it, I'd appreciate it!
Thanks!


Update: I just realized I could resolve this one way by prepending a PS= ; on the beginning of my command to temporarily blank the prompt. If there is a better way, I'd love to hear it. Thanks!

In reply to 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.