Good morning Monks!

I have a few questions for you guys, so not really too sure how to title this one... I am using Expect to automate some things over here. Some of these things are simple commands, so Expect is not really necessary per se (i.e., I won't be using expect/send functionality). Others are interactive, so I will be needing Expect.

My first question is: Expect is a rather old Perl module that has not been updated in quite some time. Is this still the go-to module for automating interactive tasks via ssh, or is there something better?

Second, since I am running some commands that I only care to get the output from, and others that are interactive (i.e., where I am using expect/send), do you think it makes sense to use Net::SSH::Perl for the tasks where I need output, and Expect for those tasks that are interactive?

Finally, the commands I am running share output, have their own output, and have quite a bit of output. I could do this:

$exp->expect($timeout, [ qr /pattern/ => sub { do things; } ] );

For each and every pattern... However, say with commandA I am expecting 40 or so different possible patterns, and with commandB I am expecting 30 or so possible patterns, 20 of which I am also expecting from commandA (i.e., shared possible patterns, union). Is there an easier way to do this then? Say something like a dispatch table where output is mapped to what to do, then I could do something like:

$exp->expect($timeout, \$dispatch_table );

Or, maybe I could even have an XML file with all the possible outputs and what to dos defined? Just wondering how some of you would tackle this one, because my mind is drawing a blank.

Thank you Monks!

In reply to A few questions regarding Expect.pm and possible alternatives 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.