Skip to content

Return matched group in ShellStream.Expect #833

Closed

Description

@NN---

Currently it returns the strings which requires me to call Regex.Match second time.

Activity

  1. IgorMilavec commented on Feb 24, 2022

    @IgorMilavec
    Collaborator

    I have created a discussion #926 for all ShellStream related issues.

  2. IgorMilavec commented on Mar 21, 2022

    @IgorMilavec
    Collaborator

    @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?

  3. NN--- commented on Mar 21, 2022

    @NN---
    Author

    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.

  4. IgorMilavec commented on Mar 21, 2022

    @IgorMilavec
    Collaborator

    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.

  5. NN--- commented on Mar 21, 2022

    @NN---
    Author

    One of usages is to wait for password prompt when sudo is called and put a password.

  6. IgorMilavec commented on Mar 21, 2022

    @IgorMilavec
    Collaborator

    So in this case you would be Expecting $".*\[sudo\] password for {RegexEscape(username)}: "?

  7. NN--- commented on Mar 21, 2022

    @NN---
    Author

    Yes, this is the idea.
    It is one of the possible usages of Expect of course.

  8. NN--- commented on Mar 21, 2022

    @NN---
    Author

    In general any command requiring input needs to wait for the prompt and only then put the text.

  9. added this to the vNext milestone on Sep 29, 2023
  10. jscarle commented on Feb 13, 2024

    @jscarle
    Contributor

    @IgorMilavec @WojciechNagorski Although the conversation is unclear, I believe this was also fixed by #1207 and #1319.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions