Junos Device CLI command giving wrong output when executed from python

349 views Asked by At

When i try to execute Device.cli(....) command from python it gives me wrong output. What could be the issue?

For example, if i execute below command on directly on Juniper Device CLI, it gives the correct output with match sadasd-sdasd-asdasd.

show configuration | display set | match sadasd-sdasd-asdasd

But if i execute the same command from Junos CLI with python, output is whole configuration instead of matching with filter string.

device = Device(host=host, user=device_ssh_user, ssh_private_key_file=device_ssh_key,
                passwd=password)
device.open()

configuration = device.cli("show configuration | display set | match sadasd-sdasd-asdasd") 
2

There are 2 answers

0
Vijay Shetty On

It is not recommended to use the cli() method in Pyez. Why? Read the below answer.

Already answered here

0
Nitin Kr On

Check if this helps

device.rpc.get_config(options={'format': 'set'})