Sorry I'm late, but better late than never!..
The connect() method in Control::CLI only handles the connection, it does not try to lock onto a prompt; only login() and cmd() do that..
So I think the original problem was that you were sending your first command while the *nix host was expecting the unique ID.
So I would suggest a cleaner approach would be the following:
$cli = new Control::CLI( Use => 'SSH', Timeout => 30, ); $cli->connect( Host => $host, Username => 'abc', Password => 'pass', ) or do { print "\tSSH connection to server ($host) could not b +e established\n"; exit; } $cli->login( Username => 'IJAF', Username_prompt => 'unique ID[:>]\s*$', ) or do { print "\tCould not get prompt from server ($host)\n"; exit; } print "\tSSH connection to server ($host) established!\n"; $output = $cli->cmd("clear"); ...
The above login() method will now supply IJAF if it sees a prompt for the unique ID; once it sees a valid prompt (whether or not it got requested for the unique ID) it will return with a true value and you can then proceed to send the commands you need with cmd()..
In reply to Re^2: Control::CLI and Additional Prompt At Login
by lgas
in thread Control::CLI and Additional Prompt At Login
by ImJustAFriend
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |