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

A way to get binary output #44

Closed
pink-red opened this issue Aug 7, 2022 · 2 comments
Closed

A way to get binary output #44

pink-red opened this issue Aug 7, 2022 · 2 comments

Comments

@pink-red
Copy link

pink-red commented Aug 7, 2022

First of all, thank you for this project! It was very easy to set up a couple of endpoints.

Now, I am trying to create another endpoint for a command which returns binary output and I'm getting an error:

"'utf-8' codec can't decode byte 0xff in position 0: invalid start byte"

Is there a way to configure an endpoint to return binary data, for example, in base64?

@eshaan7
Copy link
Owner

eshaan7 commented Aug 12, 2022

Is there a way to configure an endpoint to return binary data, for example, in base64?

You could try the unix pipe | your command to base64. For example, echo "Hello" | base64. Might need to put your command in a custom script (.sh/.py/etc) to use pipes though (refer to this example).

You may be able to use a decorator to achieve this too (example).

@pink-red
Copy link
Author

You could try the unix pipe | your command to base64.

Thank you for your suggestion. I ended up creating this wrapper script:

#!/bin/sh
<the-command> "$@" | base64 --wrap 0

and it's called like this:

shell2http.register_command(endpoint="some-enpoint", command_name="./script.sh")

Works like a charm!

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

No branches or pull requests

2 participants