Forum Discussion
mvo_65102
Jan 30, 2017Nimbostratus
Native tmsh/bash commands via REST API
Hi all,
is there a way to execute native tmsh or bash commands using the REST API?
As long as there are not all configurations controllable by REST i would like to execute some commands directly...
Satoshi_Toyosa1
Feb 02, 2017Ret. Employee
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.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects