0 votes
by (220 points)

Hi

I want to actually see the current prompt, but ReadUntil do not add the prompt and scripting.Prompt only show my mask prompt that I use to detect the prompt.

On my device the prompt changes depending on user imputs and I want to show them current prompt.

1 Answer

0 votes
by (148k points)

Unfortunately, the underlying protocols don't support any functionality that would make it possible for a client to simply ask the server for the current prompt. Instead, we either rely on heuristics that use knowledge of common terminal behavior to detect the prompt. Unfortunately, this is far from perfect and does not handle sudden changes of the prompt. SSH or telnet terminals were not actually designed with automation in mind. And actually, with some shells, even human terminal operators occasionally have trouble distinguishing what's actually the prompt and what is just command output.

Instead, the usual approach is to explicitly set Scripting.Prompt property based on currently performed actions - for example, when invoking the common "ftp" command-line client, you would set the Prompt to match "ftp>".

by (220 points)
Thanks, but I still do not understand, sorry.

Ok, so the actual prompt is not part of the response from the device? I was thinking that the scripting.ReadUntil only skipped the prompt part when it was detected.

What do you do the matching on when you do the prompt detection?
In my case I use scripting.Prompt="mask:Router*#"; to detect the different prompts in the cisco router and I guess you have to compare it to something? It is that "something" I would like to fetch :)
by (148k points)
The prompt is part of the response from the device, but there is nothing in the response to indicate which part of the response is the actual response and which part is the prompt.

The basic approach in DetectPrompt method is to send the "Enter" key and wait for the server to respond with some common prompt-like pattern. It's a bit more complex than this, but this is the main approach.

But if you simply need to retrieve an already-detected prompt, then try using WaitFor instead of ReadUntil. Unlike ReadUntil, the WaitFor method will return an instance of ScriptMatch, which makes it possible to determine what was actually matched. (And to get the response received before the match, use Scripting object's ReceivedData property.)
...