Forum Discussion
apresti12
Nimbostratus
Feb 28, 2017500 Error When Posting Bash Command - PowerShell
Does anyone know why a multi argument bash command fails but a single argument command does not fail? It almost acts as if the "md5sum" command in this example is ran without taking into consideration the filepath.
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }
$Contenttype = "application/json"
$Body = '{
"kind": "tm:util:bash:runstate",
"command":"run",
"utilCmdArgs":"-c md5sum /shared/images/IMAGENAME"
}'
Invoke-RestMethod -Header $headers -Uri https://localhost/mgmt/tm/util/bash -ContentType $Contenttype -Method Post -Body $Body | format-table -WrapThis code will result in a 500 error, however, if I change the utilCmdArgs to a command such as "pwd" it succeeds.
kind command utilCmdArgs commandResult
---- ------- ----------- -------------
tm:util:bash:runstate run -c pwd /var/service/icrd Has anyone experienced this before or ran into a similar issue?
1 Reply
This one works for me:
[nielsvs@localhost ~]$ curl -sk -u apiuser:secret -H 'Content-Type: application/json' -X POST -d '{"command": "run", "utilCmdArgs": "-c \"md5sum /shared/images/BIGIP-13.0.0.0.0.1645.iso\""}' https://10.23.92.5/mgmt/tm/util/bash | jq { "kind": "tm:util:bash:runstate", "command": "run", "utilCmdArgs": "-c \"md5sum /shared/images/BIGIP-13.0.0.0.0.1645.iso\"", "commandResult": "70c21457c96b8a1381a0efc62fcb94f2 /shared/images/BIGIP-13.0.0.0.0.1645.iso\n" } [nielsvs@localhost ~]$Maybe you should use the extra quotes when using the '-c'?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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