Subject: | find_prompt() doesn't report whether a prompt was found or not |
Date: | Thu, 14 Sep 2017 15:19:58 +1000 |
To: | bug-Net-CLI-Interact [...] rt.cpan.org |
From: | Alexander Zangerl <alexz [...] opmantek.com> |
scenario: we have a session that has worked up to a point, but now
a command we've issued is stuck without producing output,
which causes n::a::s/n::c::i to time out.
we'd like to try to get the session state back into sync (maybe the command
will produce some output, just a little delayed), so we'd like to
ask n::c::i to look for a prompt for a little bit longer, and tell us
whether that has worked or not.
the docs say find_prompt() returns if and only if a prompt was found,
and that it dies otherwise. that does not match the implementation.
short of the network going down find_prompt() always returns
regardless of whether it has found a prompt or not.
that's because the logic in role/prompt.pm goes for death if and
only if the session has no prompt set - but the prompt from earlier
successful interactions is NOT cleared.
ie. line 133 ff.
else {
if (not $self->has_set_prompt) {
# trouble... we were asked to find a prompt but failed :-(
workaround to force find_prompt to terminate on failure:
run $session->nci->unset_prompt; just before calling $session->find_prompt.
i think the proper fix would be for find_prompt() to clear the session's prompt
status before it starts its loop.
regards
az
--
Alexander Zangerl
email: alexz@opmantek.com
skype: alex.zangerl
mobile: +61 415 482 341
web: https://community.opmantek.com/