I have a requirement where, a python
script running in a Juniper router shell needs to execute some commands in vty
console of the FPC. I cannot use vty c
because it may not work properly in all platforms. However, I can use vty fpc0
and then execute the command and exit from there.
Is there a way to execute vty
command using PyEZ
? If yes, please provide the syntax.
The StartShell
class assumes the ability to make a new SSH connection to the target device using port 22. That might not always be a good assumption.
An alternative to using StartShell
is to use the RPC equivalent to the request pfe execute
command. Here's an example:
>>> resp = dev.rpc.request_pfe_execute(target='fpc0', command='show version')
>>> print resp.text
SENT: Ukern command: show version
GOT:
GOT:
GOT: Juniper Embedded Microkernel Version 15.1F4.15
GOT: Built by builder on 2015-12-23 18:11:49 UTC
GOT: Copyright (C) 1998-2015, Juniper Networks, Inc.
GOT: All rights reserved.
GOT:
GOT:
GOT: RMPC platform (1200Mhz QorIQ P2020 processor, 3584MB memory, 512KB flash)
GOT: Current time : Sep 2 15:35:42.409859
GOT: Elapsed time : 27+19:14:41
LOCAL: End of file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With