Posted on July 6, 2016 1:56 pm
 |  Asked by Ronald David Hurtado Ulfe
 |  1611 views
1
0
Print Friendly, PDF & Email

Anyone getting this error  “Command not permitted via API access. To run a bash command over the Command API,  use the ‘timeout  <seconds>’ option.”

Is there any way to run the next using the API?

{
“jsonrpc”: “2.0”,
“method”: “runCmds”,
“params”: {
“format”: “json”,
“timestamps”: false,
“cmds”: [
“enable”,
“show version”,
“bash ifconfig”
],
“version”: 1
},
“id”: “EapiExplorer-1”
}

The answer we get is

{
“jsonrpc”: “2.0”,
“id”: “EapiExplorer-1”,
“error”: {
“data”: [
{},
{
“modelName”: “DCS-7048T-A-F”,
“internalVersion”: “4.15.7M-3284043.4157M”,
“systemMacAddress”: “00:1c:73:61:6b:57”,
“serialNumber”: “JPE14120767”,
“memTotal”: 3978148,
“bootupTimestamp”: 1467714813.72,
“memFree”: 613872,
“version”: “4.15.7M”,
“architecture”: “i386”,
“isIntlVersion”: false,
“internalBuildId”: “b0b0dff8-c9ca-40cc-a625-7fd3c8c76ebd”,
“hardwareRevision”: “01.07”
},
{
“errors”: [
“Command not permitted via API access. To run a bash command over the Command API, use the ‘timeout ‘ option.”
]
}
],
“message”: “CLI command 3 of 3 ‘bash ifconfig’ failed: incompatible command”,
“code”: 1004
}
}

1
Posted by Lokesh Charora
Answered on July 6, 2016 2:10 pm

You can try running the following command:

bash timeout 1 ifconfig

 

 

Good point, this works.

Something like:
eapi.runCmds( 1, [ ’enable’,’bash timeout 10 ifconfig’ ] )

Where eapi is your server connection:
eapi = Server( ”unix:/var/run/command-api.sock” )

(John Gill at July 15, 2016 10:10 pm)

Post your Answer

You must be logged in to post an answer.