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

Ability to pass command to altis stack ssh and pipe ouput #16

Open
joehoyle opened this issue Aug 10, 2023 · 2 comments
Open

Ability to pass command to altis stack ssh and pipe ouput #16

joehoyle opened this issue Aug 10, 2023 · 2 comments

Comments

@joehoyle
Copy link
Member

User Story

As a CLI user I am able to pass a command to execute to altis-cli stack ssh such as wp user list and then pipe the output to my local machine. For example, something like altis-cli stack ssh altis-demo -- wp user list | grep joe (in this case grep is being run on my local machine.

I would also like to pipe data in to a command, for example: echo joe | altis-cli stack ssh altis-demo -- wp user get.


I chatted to @rmccue about the feasibility to doing these, and there are a few low-level challenges that we need to overcome to be able to implement this. As I understand it:

  1. We need to be able to change the "initial" command when ssh is run, as currently it will output MOTD and other boilerplate as part of setting up the SSH sessions. If developers want to just be able to just run a command and pipe output, we can't have any of the initial data.
  2. Altis Dashbaord APIs need to be updated to allow passing the initial command, as we can't run the command client-side in the interactive sessions, as there's no easy to way understand when the command might be complete and exit the program.
  3. Currently the session's SSH output is all a single stream of data, so there's no way to split stdout / stderr in pipes on the client machine. This means if something like wp user list output PHP errors or any other error, it would be in stdout and piped along with the list of users. This makes the data useless in many situations. There's an open issue on [session-manager-plugin] "aws ssm start-session" should print debug output to stderr instead of stdout aws/amazon-ssm-agent#358 (2.5 years old) to address this, but it doesn't look like there's any progress.
@johnbillion
Copy link
Member

I don't know if it affects the implementation, but redirection should work too (as Joe and I chatted about earlier today). For example:

altis-cli stack ssh altis-demo -- wp user list > users.json

The end result is that users.json gets saved on my local machine.

@rmccue
Copy link
Member

rmccue commented Sep 6, 2023

Just to note, you can do this in two commands if necessary:

altis-cli ssh altis-demo

  wp user list > /tmp/users.json

altis-cli scp altis-demo:/tmp/users.json ./

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

3 participants