AnsweredAssumed Answered

parsing  mgmt_cli using JQ delivers not expected result

Question asked by Sebastian Gxxx on Jun 15, 2018
Latest reply on Jun 17, 2018 by Vincent Bacher

parsing  mgmt_cli using JQ delivers not expected result

 

I am on R80.10 SMS T462 and run the following command:

[Expert@R80.10:0]# mgmt_cli login user admin password vpn123 > id.txt

[Expert@R80.10:0]# mgmt_cli show service-tcp -s id.txt name http --format json | jq '{name: .name, port: .port}'
{
  "name": null,
  "port": null
}

I would have expected to get the following result :

{
  "name": "http",
  "port": "80"
}

when I run the following command I get correct results:

 

[Expert@R80.10:0]# mgmt_cli show service-tcp -s id.txt name http --format json > input.txt

[Expert@R80.10:0]# cat input.txt | jq '{name: .name, port: .port}'
{
  "name": "http",
  "port": "80"
}

 

 

the input looks like follows (result of "mgmt_cli show service-tcp name http") :

 

{
  "uid" : "97aeb3d4-9aea-11d5-bd16-0090272ccb30",
  "name" : "http",
  "type" : "service-tcp",
  "domain" : {
    "uid" : "a0bbbc99-adef-4ef8-bb6d-defdefdefdef",
    "name" : "Check Point Data",
    "domain-type" : "data domain"
  },
  "port" : "80",
  "protocol" : "HTTP",
  "match-by-protocol-signature" : false,
  "override-default-settings" : true,
  "session-timeout" : 3600,
  "use-default-session-timeout" : true,
  "match-for-any" : true,
  "sync-connections-on-cluster" : false,
  "aggressive-aging" : {
    "enable" : true,
    "timeout" : 60,
    "use-default-timeout" : false,
    "default-timeout" : 60
  },

....

.....

 

What am I doing wrong ?

 

Outcomes