Hi PerlMonks,

I have automated an interactive remote ssh session which executes a command , looks for a warning message and then provides the option "y" in response to the warning message.

The issue that i am facing is that the option "y" is provided a second time on the command line generating an error.

How do i get to print this input option only once in response to the warning message and not a second time.

The codelet is mentioned below ($confref->{'ssh_session'} is the spawn id of the ssh session):

$confref->{'ssh_session'}->clear_accum(); $confref->{'ssh_session'}->send("$cmd\n"); $confref->{'ssh_session'}->expect( undef,[ '{y|n}:', sub { my $fh = shift; print $fh "y\n"; $pass_flag = 1; exp_continue; } ] ,-re, qr'./*> $' ); $confref->{'ssh_session'}->clear_accum(); $info = $confref->{'ssh_session'}->before();

The output in $info is mentioned below :


f3050-233-10::> volume move -vserver f3050_233_10_vserver_cifs_1 -volume f3050_233_10_vserver_cifs_1_dynamic_vol1 -destination-aggregate aggr0 -foreground true

WARNING: You are about to move a volume to a root aggregate. This may cause severe performance or stability problems and therefore is not recommended.
Do you want to proceed? {y|n}: y
Job 498 Job succeeded: Successful 105.

f3050-233-10::> y

ERROR: "y" is not a recognized command

f3050-233-10::> Thanks in Advance!


In reply to Perl Send-Expect Input discrepancy by perlpal

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.