You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@nn I'm trying to better understand usage patterns related to Expect API. Can you please explain how you use it and if possible provide a proto code for it?
The API reads the data and tries to
match it with the given pattern.
Once it is matched the method returns.
The problem here is that I want the matched groups what API doesn't give.
If you talk generally about the API, it would be better to have a Stream abstraction over SSH, then such code could be implemented for any stream.
Yes, I know what the Expect API is supposed to do. :)
What I'm asking is how you are using it? I agree that having such functionality for any Stream would be beneficial, but to design it properly, we first need to understand how it is used in the client code. So if you could describe why and how you are using it would help me very much.
Activity
IgorMilavec commentedon Feb 24, 2022
I have created a discussion #926 for all ShellStream related issues.
IgorMilavec commentedon Mar 21, 2022
@nn I'm trying to better understand usage patterns related to Expect API. Can you please explain how you use it and if possible provide a proto code for it?
NN--- commentedon Mar 21, 2022
The API reads the data and tries to
match it with the given pattern.
Once it is matched the method returns.
The problem here is that I want the matched groups what API doesn't give.
If you talk generally about the API, it would be better to have a Stream abstraction over SSH, then such code could be implemented for any stream.
IgorMilavec commentedon Mar 21, 2022
Yes, I know what the Expect API is supposed to do. :)
What I'm asking is how you are using it? I agree that having such functionality for any Stream would be beneficial, but to design it properly, we first need to understand how it is used in the client code. So if you could describe why and how you are using it would help me very much.
NN--- commentedon Mar 21, 2022
One of usages is to wait for password prompt when
sudois called and put a password.IgorMilavec commentedon Mar 21, 2022
So in this case you would be Expecting
$".*\[sudo\] password for {RegexEscape(username)}: "?NN--- commentedon Mar 21, 2022
Yes, this is the idea.
It is one of the possible usages of Expect of course.
NN--- commentedon Mar 21, 2022
In general any command requiring input needs to wait for the prompt and only then put the text.
jscarle commentedon Feb 13, 2024
@IgorMilavec @WojciechNagorski Although the conversation is unclear, I believe this was also fixed by #1207 and #1319.