perlpal has asked for the wisdom of the Perl Monks concerning the following question:
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Send-Expect Input discrepancy
by jethro (Monsignor) on Jul 08, 2009 at 12:12 UTC | |
by perlpal (Scribe) on Jul 08, 2009 at 12:39 UTC | |
|
Re: Perl Send-Expect Input discrepancy
by apl (Monsignor) on Jul 08, 2009 at 12:06 UTC | |
by perlpal (Scribe) on Jul 08, 2009 at 12:17 UTC |