Forum Discussion
Satoshi_Toyosa1
Feb 02, 2017Employee
If you are looking for the iControl REST endpoint for executing a Unix command, that's
/mgmt/tm/util/bash
. Here's an example (for ls /tmp
😞
curl -sku user:password -X POST -H "Content-type: application/json" \
-d "{\"command\":\"run\", \"utilCmdArgs\": \"-c 'ls /tmp'\"}" \
https:///mgmt/tm/util/bash
You can run a tmsh command in the same manner (e.g.,
tmsh list ltm virtual
😞
curl -sku user:password -X POST -H "Content-type: application/json" \
-d "{\"command\":\"run\", \"utilCmdArgs\": \"-c 'tmsh list ltm virtual'\"}" \
https:///mgmt/tm/util/bash
Output lines are concatenated (not easy to read), so you may want to parse it by piping the result to
python -m json.tool | sed 's/\\n/\n/g'
Note that you will get 50x error when the execution of the specified command takes longer than a predefined timeout (about 60-90 seconds).
For more on the API, please refer to iControl REST API Reference Version 12.0.