[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: libssh and screen prompts


Thanks for all your help. I'm enhancing my test program based on your
feed-back.

On Tue, Dec 8, 2009 at 10:22 AM, Norbert Kiesel <nkiesel@xxxxxxxxxxxxxxx>wrote:

>  On Tue, 2009-12-08 at 09:34 -0500, Barbara Knysz wrote:
> > I have created a test program that sends a command, and then recieves
> > the output.
> > However, I also need to examine the screen prompt to identify aspects
> > of work flow, such as then dynamic discovery of the the necessity of
> > an 'enable' password..
> >
> > Does libssh handle this?
>
> No it does not.  What it does is giving you a channel (actually 2, but
> you can ignore the stderr for your purposes I think) to read/write to
> the other end.  From the "enable" password comment above I assume the
> endpoint you are talking to is something like an IOS router.  You have
> to do the following:
> 1) figure out how to know that the endpoint is done talking to you.
> This is either done by just continue to read until the endpoint no
> longer sends anything (obviously you need a poll or read with timeout
> here), or by looking at what the endpoint sent back and searching for
> the prompt.  The second solution is generally faster but can be tricky,
> especially if the endpoint allows to change the prompt and you have no
> control over it.
> 2) Either know what state you end in after login (i.e. unprivileged or
> privileged mode), or analyse what the endpoint sent back.  Then either
> send (or not) the string "enable", wait (using one of the 2 solution
> from (1) for the password promp)t, then send the password, then wait for
> the enable prompt.
>
> I did something like this in the past (sorry can't share the code) and
> coded a little state machine for the whole login (with states like
> WAITING_FOR_ENABLE_PASSWORD_QUESTION, WAITING_FOR_ENABLE_PROMPT, ...).
>
> Hope that helps.
>
> Best,
>  Norbert
>
>
>
>
>

References:
libssh and screen promptsBarbara Knysz <bknysz@xxxxxxxxx>
Re: libssh and screen promptsNorbert Kiesel <nkiesel@xxxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org