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?
In reply to Perl Expect is not sending multiple commands by essej1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |