AnsweredAssumed Answered

API: How to use args in run-script ?

Question asked by Andrei Popisteru Employee on Jun 26, 2018
Latest reply on Oct 11, 2018 by Mohamad Awaisy

Hello CheckMates!


Could you provide me a hint on how to use args parameter in API (v1.1) call run-script to pass arguments to an OS command or script ? Using args with mgmt._cli, postman, SCconsole returns a failed task.


e. g. :


mgmt._cli -r true -f json run-script script-name "ping" script "ping" args " -c1" targets.1 "mgmt._server_itself"




"mgmt._server_itself - ping"  failed  (100%)
<omitted for brevity>
    "task-id" : "e1f9a669-2cf8-4248-bee7-437902810e9b",
    "task-name" : "mgmt._server_itself - ping",
    "status" : "failed",
      "statusCode" : "failed",
      "statusDescription" : "Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline],  [-p pattern] [-s packetsize] [-t ttl] [-I interface or address


as if arguments in args string value are not passed to bash. Various arguments and escape sequences tried, same result.


Passing all arguments in script value works:


mgmt._cli -r true -f json run-script script-name "ping" script "ping -c1" targets.1 "mgmt._server_itself"




"mgmt._server_itself - ping"  succeeded  (100%)
    "task-id" : "0751191e-9fed-4bcf-851f-b97645dcea4c",
    "task-name" : "mgmt_server_itself - ping",
    "status" : "succeeded",
      "statusCode" : "succeeded",
      "statusDescription" : "PING ( 56(84) bytes of data. 64 bytes from 172.17.xx.2: icmp_seq=1 ttl=128 time=0.110 ms,  ---
 ping statistics ---, 1 packets transmitted,  1...",


Screened api.elg, cpm.elg, fwm.elg for clues - didn't understand how script string and args string are passed to bash.


Environment: R80.10, JHF T112 


Thank you for your time,