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
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.
The text was updated successfully, but these errors were encountered:
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
orecho $PATH
).To my knowledge and countless tries, this is not possible with
session.run()
orsession.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
andenvironment
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.
The text was updated successfully, but these errors were encountered: