I'm progressing a bit. I pass in post an exec command (df), and catch the return of the command via the operation and the secret But if I do not set timeout in the last line, the curl command remains blocked. Someone would have any idea ?
#! /bin/bash t=$(/usr/bin/curl -s -k --cert .config/lxc/client.crt --key .config/lxc/client.key https://localhost:8443/1.0/containers/wondrous-mackerel/exec -X POST -d '{"command": ["/bin/df", "-h", "/"], "wait-for-websocket": true, "interactive": true }') operation=$(echo $t | jq .operation|tr -d '"') secret=$(echo $t |jq '.metadata.metadata.fds[]'|head -n 1| tr -d '"') x=$(curl -m 1 -i -N --header 'Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==' --header 'Sec-WebSocket-Version: 13' -H 'Connection: Upgrade' -H 'Upgrade: websocket' -s -k --cert .config/lxc/client.crt --key .config/lxc/client.key https://localhost:8443 $operation/websocket?secret=$secret) echo $x 2016-12-23 18:47 GMT+01:00 Robert Johnson <rober...@bendtel.com>: > I've been working on obtaining two way communications with the /exec URI, > but your needs may more simple then mine. > > When you POST to /exec, you probably want to include the 'record-output' > key with a (boolean) value of true. ie > > '{"command": ["df -f /"], "record-output": true}' > > The doc's state that stdout and stderr will be redirected to a log file. > > It doesn't state where the log file is; but I'm willing to bet that the > reply will include a path that you can subsequently GET. > > If this works for you, let me know, I'm interested in at least obtaining > the output from some commands. > > On 12/23/2016 05:02 AM, laurent ducos wrote: > >> Hello. >> >> Is there a solution to get the return of a command launch by lxd exec API >> ? >> >> curl -s --unix-socket /var/lib/lxd/unix.socket >> a/1.0/containers/$CONTAINER/exec -X POST -d '{"command": ["df -f /"]}' | >> jq . >> >> I would like to see something like this in return of the command. >> >> output: /dev/sda5 15G 4,6G 9,8G 32% / >> >> >> _______________________________________________ >> lxc-users mailing list >> lxc-users@lists.linuxcontainers.org >> http://lists.linuxcontainers.org/listinfo/lxc-users >> >> _______________________________________________ > lxc-users mailing list > lxc-users@lists.linuxcontainers.org > http://lists.linuxcontainers.org/listinfo/lxc-users
_______________________________________________ lxc-users mailing list lxc-users@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-users