essej1 has asked for the wisdom of the Perl Monks concerning the following question:
OK, I've got Perl Expect to sort of work. I can login via ssh and send SOME commands. The issue is that after sending a few commands subsequent prints aren't being sent. For example (code snippet - after the login completes)
$exp->expect(10, $ssh_host, sub { print $exp "term length 0\n"; } ); $exp->expect(10, $ssh_host, sub { print $exp "sh clock\n"; } ); $exp->expect(10, $ssh_host, sub { print $log_fh "\n==> A\n"; # print to log to show I'm there print $exp "\nsh ver\n"; print $log_fh "\n==> B\n"; } ); $exp->exp_internal(0); $exp->expect(10, $ssh_host, sub { print $log_fh "\n==> Z\n"; # print to log to show I'm there print $exp "exit\n"; print $log_fh "\n==> Y\n"; }
When I look at the log I see the '==>' prints but the second send command (print $exp "<what ever>" isn't being actually sent. I can change the order ('sh ver' first, 'sh clock' second and I get the same thing. The second command just doesn't seem to be sent. Is there some I'm missing?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Expect is not sending multiple commands
by Argel (Prior) on Sep 17, 2012 at 20:51 UTC | |
by essej1 (Novice) on Sep 18, 2012 at 15:33 UTC | |
by Argel (Prior) on Sep 18, 2012 at 18:08 UTC |