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

Are there any examples for streaming the output of a command? #150

Closed
carterbryden opened this issue Oct 16, 2019 · 2 comments
Closed

Are there any examples for streaming the output of a command? #150

carterbryden opened this issue Oct 16, 2019 · 2 comments

Comments

@carterbryden
Copy link

That is, if I do SSHKit.run("wget someaddress.com/file"), can we stream the output as it comes in rather than wait for it to all completely finish?

@pmeinhardt
Copy link
Contributor

Great question! 💚

If you look at SSHKit.SSH.run/3, it allows you to pass a :fun option (for maximum fun 😁).
The default for that is to capture/2 all of the output into a list.

You might be able to do streaming with this lower-level API by providing a custom function there for now? 🤔

Otherwise, I've actually been thinking about changing SSHKit's interface to behave more similar to that of mint, i.e. the process that calls SSHKit.run/2 would just receive messages as a result.

Happy if you could provide feedback on both a potential solution with the current API and maybe thoughts on the idea of a mint-like interface. ✌️

@pmeinhardt
Copy link
Contributor

There has not been any activity/feedback on this in more than a year, so I will go ahead and close this.
Please feel free to re-open, Carter, in case we can be of help.

In the meanwhile, we're working on a new version of the package which should make it easier to stream output directly. You can follow the work in this PR if you're interested: #164

There are some working examples showcasing the new APIs. It's still a work-in-progress, but might give you some ideas:
https://github.com/bitcrowd/sshkit.ex/tree/v1/examples

✌️

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

2 participants