daphnaw has asked for the wisdom of the Perl Monks concerning the following question:
$cmd is printed to the console: (cd /export/home/ana37/local/scripts/embedded_oracle; /export/home/ana37/local/scripts/embedded_oracle/perl/bin/perl-static oracle.pl --host localhost --remove --install --oraclepw Fx9qYfmz --oracleuser oracle --oraclehome /export/home/oracle --rootpw admin --datafiles /export/home/oracle/oradata/anadb --redo /export/home/oracle/redo --recovery /export/home/oracle/arch --smtp_server outbound.cisco.com --email_recipient dwasserm@cisco.com)my $tmp_dir = Cwd::abs_path(dirname($0)); eval "use Expect;"; if ($@) { crash "Could not find Expect"; } my $exp = Expect->new; $exp->raw_pty(0); $exp->log_stdout(0); $exp->spawn("su - root"); $exp->expect($timeout, [ '-re', 'Password:\s*$' => sub { $exp->send("$root_password\n"); }], [ timeout => sub { die "Timeout" }], ); $exp->expect($timeout, [ '-re', '\][#%]\s*$' => sub {} ], [ timeout => sub { die "Timeout, no prompt" } ], ); my $script = basename $0; $cmd = "cd $tmp_dir; $^X $script $cmd"; PERLLIB ''; $^X $script $cmd"; <b>$cmd = "($cmd)";</b> my $result = $exp->send("$cmd\n"); my $success; my $end_string_seen; my $time_cnt = 1000; $exp->expect($timeout, [ '-re', '\][#%]\s*$'=> sub {} ], ['-re', $END_STRING => sub { $end_string_seen = 1;} ], [ '-re', $SUCCESS_STRING => sub { $success = 1; } ], [ timeout => sub { print $exp->before; $exp->clear_accum; $time_cnt--; if ($time_cnt > 0) { exp_continue(); } else { die "Timeout, no prompt"; } } ], ); if ($success) { $exp->soft_close(); } else { crash("Installation failed"); } exit 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Expect prints command to console
by Illuminatus (Curate) on Jun 21, 2010 at 00:26 UTC | |
by daphnaw (Acolyte) on Jun 21, 2010 at 15:29 UTC | |
|
Re: Expect prints command to console
by Anonymous Monk on Apr 08, 2016 at 14:15 UTC | |
|
Re: Expect prints command to console
by Krambambuli (Curate) on Jun 21, 2010 at 15:50 UTC |