# Run a command inside container using SDK

**URL:** <https://forums.balena.io/t/run-a-command-inside-container-using-sdk/304281>\
**Category:** balenaOS\
**Created:** [April 27, 2021, 3:52pm UTC](https://forums.balena.io/t/run-a-command-inside-container-using-sdk/304281 "2021-04-27T15:52:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hunter](https://avatars.discourse-cdn.com/v4/letter/h/ba9def/32.png) [@hunter](https://forums.balena.io/u/hunter)\
**Post date:** [April 27, 2021, 3:52pm UTC](https://forums.balena.io/t/run-a-command-inside-container-using-sdk/304281/1 "2021-04-27T15:52:10Z")

</div>

I am trying to run a .sh script (that sends an image to our database from the device) through our companies admin dashboard. Is there a way to use the SDK to push a bash exec command to a specific container?

For clarity, this is what I am trying to do:

1. Our admin logs into our dashboard
2. Our admin want to retrieve an image from the device
3. Admin clicks ‘Retrieve Image’
4. Our API connects to Balena SDK and runs ‘./send\_image.sh’
5. The response from ./send\_image.sh script is returned to the admin dashboard

Thanks

---

<div class="post-metadata">

**Author:** ![tmigone](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/tmigone/32/2814_2.png) [@tmigone](https://forums.balena.io/u/tmigone)\
**Post date:** [April 27, 2021, 7:12pm UTC](https://forums.balena.io/t/run-a-command-inside-container-using-sdk/304281/4 "2021-04-27T19:12:02Z")

</div>

Hi @hunter, I don’t think it’s possible to use the SDK to push commands to a device. You could somewhat hack the CLI to achieve part of it though, would that work for you?

Here is what I would do. You can pipe commands to the SSH CLI command: `echo "uptime; exit;" | balena ssh <DEVICE_UUID>`. This will run `uptime` on the device’s hostOS, send the result back and exit. If you instead pipe the contents of a script you could run a script that uses balenaEngine to connect to the container from the hostOS and then run a command there. Let me exemplify.

You would need to run:

```auto
cat script.sh | balena ssh <DEVICE_UUID>

```

And your `script.sh` would look like this:

```auto
balena exec -it <CONTAINER_ID> sh -c "uptime; exit;"
exit;

```

This will run `uptime` in container `<CONTAINER_ID>` which is running on device `<DEVICE_UUID>`.
