Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell without Streams #85

Closed
Blazym8 opened this issue Aug 9, 2023 · 0 comments
Closed

Shell without Streams #85

Blazym8 opened this issue Aug 9, 2023 · 0 comments

Comments

@Blazym8
Copy link

Blazym8 commented Aug 9, 2023

I would like to know if theres a way to run a command inside a remote shell, which simply returns the response instead of using streams. Problem is, that anytime a user logs in, it should check if certain commands are installed (either by running command --version or echo $PATH).
To my knowledge and countless tries, this is not possible with session.run() or session.execute(), since they cant invoke the environment variables. But when you spawn a shell and .write() to it, the command gets found and is executable. The issue is then, that the stdout and stderr streams emit at unknown times, so that its not easy to know when (and where[inside the listed chunks]) to check for the final response i need.

I've seen the params runInPty and environment in the docs, but either way i tried i didn't achieve the desired outcome (and im not sure what its expecting for environment [Map<String, String>]).
I could think of spawning a new shell every time i want to execute a new command and then once it finishes i can iterate through the response, but i cant think that this is very efficient.
Maybe a sort of convenience function shell.run() could be implemented that returns the response, once the response to this specific command finishes, but im unaware of any callback or property that tells you if the current response is done, so you would have to iterate through the list of chunks of responses, regex find your first input and the next input and everything inbetween would be the response.

As you can probably tell im kinda in the dark right now and would appreciate a comment on how to efficiently go about it, or how you imagined to process the response of one specific command in a shell.

@Blazym8 Blazym8 closed this as completed Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant