Forum Discussion
AaronMLong_1021
Cirrus
Jul 28, 2017Authentication problems with iControl rest and bash
I have a strange problem: I wrote a script which invokes a iControl rest API call (with cURL), which, if I execute the curl command at my bash prompt, it works fine. however, running it from within c...
cjunior
Nacreous
Jul 28, 2017I think I would do it a bit differently, but I think you're being betrayed by the quotes during command evaluation. Could you try this way?
Stub to test config sync with iControl rest API
LB_PWD=''
PREFIX="curl -sk -u 'admin:$LB_PWD' -H 'Content-Type: application/json'"
function syncLBConfig {
local LB=$1
local GROUP=$2
local JSON="{\"command\":\"run\",\"utilCmdArgs\":\"config-sync to-group ${GROUP}\"}"
local URI="/mgmt/tm/cm"
local CMD="${PREFIX} -X POST -d '${JSON}' https://${LB}${URI}"
echo $CMD
RESPONSE=$( eval ${CMD} )
echo $RESPONSE
}
LB_NAME="f5ltm1.example.com"
HA_GROUP="failover-group"
syncLBConfig $LB_NAME $HA_GROUP
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