subprocess – CISCO IOS-XR, Python3.7, Not capable of run instructions like ‘ls’ and ‘df’ on Cisco router

0
3


Cisco ios-xr router utilizing CLI:

RP/0/RP0#present model

Thu Nov 25 07:53:59.103 UTC

Cisco IOS XR Software program, Model 6.5.32.11I

Copyright (c) 2013-2020 by Cisco Techniques, Inc.

RP/0/RP0#run

Thu Nov 25 07:54:05.231 UTC

[xr-vm_node0_RP0_CPU0:~]$df

Filesystem 1K-blocks Used Accessible Use% Mounted on

rootfs 3966080 1332040 2412860 36% /

76892 11848320 43% /mnt/eu/vdd

[xr-vm_node0_RP0_CPU0:~]$

Utilizing python:
I’m able to run present instructions utilizing Connecthandler .ship.command:

from netmiko import ConnectHandler
import subprocess
Network_Device = {"host": "10.111.22.333", "username": "USER123", "password": "Pass123",     "device_type": "cisco_xr",}

Join = ConnectHandler(**Network_Device)
Join.allow()
version1 = "present model"
print(Join.send_command(version1))

However not capable of run ‘df’ or ‘ls’ instructions, as not capable of attain bash immediate i attain by working ‘run’ command on router.

I attempted:

disk1files = subprocess.run("df", stdout=subprocess.PIPE)
print(disk1files.stdout.decode())

However appears its incorrect. Please counsel the suitable library or code I can use right here.

That is my first query right here, so bear some foolish questions or errors achieved in code

LEAVE A REPLY

Please enter your comment!
Please enter your name here