# Execute api to run remote commands for containers is not working

**URL:** <https://forums.suse.com/t/execute-api-to-run-remote-commands-for-containers-is-not-working/2895>\
**Category:** Rancher 1.x\
**Created:** [May 24, 2016, 3:18pm UTC](https://forums.suse.com/t/execute-api-to-run-remote-commands-for-containers-is-not-working/2895 "2016-05-24T15:18:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaranto](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@amaranto](https://forums.suse.com/u/amaranto)\
**Post date:** [May 24, 2016, 3:18pm UTC](https://forums.suse.com/t/execute-api-to-run-remote-commands-for-containers-is-not-working/2895/1 "2016-05-24T15:18:28Z")

</div>

I am trying to execute remote commands into a container, using Rancher API. I run the following command, and the outcome is a token id and a web socket url. The commands pass via array don’t work. I’ve tried using /bin/sh without success . Could anyone help me with that ?

Command :  
curl -u “${CATTLE\_ACCESS\_KEY}:${CATTLE\_SECRET\_KEY}” -X POST -H ‘Accept: application/json’ -H ‘Content-Type: application/json’ -d ‘{“attachStdin”:false, “attachStdout”:false, “command”:[“service”, “apache-perl”, “stop”], “tty”:false}’ “$RANCHER\_URL/v1/projects/1a5/containers/1i156/?action=execute”

Output:  
{“id”:null,“type”:“hostAccess”,“links”:{},“actions”:{},“token”:"eyJhbGc…XXX,“url”:“ws://rancher:8080/v1/exec/”}

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [May 24, 2016, 4:37pm UTC](https://forums.suse.com/t/execute-api-to-run-remote-commands-for-containers-is-not-working/2895/2 "2016-05-24T16:37:43Z")

</div>

The action just gives you back a URL and a signed token, which contains the command. You have to open a websocket connection to that `url` to actually execute the command, and send the token either as a `Authorization: Bearer <token>` header or added on to the URL as a `?token=<token>` query param.

---

<div class="post-metadata">

**Author:** ![amaranto](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@amaranto](https://forums.suse.com/u/amaranto)\
**Post date:** [May 24, 2016, 6:11pm UTC](https://forums.suse.com/t/execute-api-to-run-remote-commands-for-containers-is-not-working/2895/3 "2016-05-24T18:11:56Z")

</div>

Thanks vicent ! I’ve got it, so i’ll use websocket if there are not another way, regards .
