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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.