Forum Discussion
1 Reply
Sort By
Something like this should work. This basic example is in python, using the requests module and the json module to convert the dict to json.
import requests import json s = requests.session() s.auth = ('admin','admin') s.verify = False ip = "some.IP" url = "/mgmt/tm/util/bash" payload = { "command":"run", "utilCmdArgs":"-c 'mkdir /var/config/rest/downloads/tmp'" } resp = s.post("https://"+ip+url, data=json.dumps(payload)) print resp.text Returns: {"kind":"tm:util:bash:runstate","utilCmdArgs":"-c 'mkdir /var/config/rest/downloads/tmp'","command":"run","commandResult":"mkdir: cannot create directory `/var/config/rest/downloads/tmp': File exists\n"}
The equivalent command in tmsh would be: run /util bash -c 'mkdir /var/config/rest/downloads/tmp'
Now I don't know how well supported this method is or if it will continue to exist, but it works for me.