Executing vty commands in Juniper routers using PyEZ
<p>I have a requirement where, a <code>python</code> script running in a Juniper router shell needs to execute some commands in <code>vty</code> console of the FPC. I cannot use <code>vty Â­c</code> because it may not work properly in all platforms. However, I can use <code>vty fpc0</code> and then execute the command and exit from there.</p>

<p>Is there a way to execute <code>vty</code> command using <code>PyEZ</code>? If yes, please provide the syntax. </p>

<p>The <code>StartShell</code> 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.</p>

<p>An alternative to using <code>StartShell</code> is to use the RPC equivalent to the <code>request pfe execute</code> command. Here's an example:</p>

<pre><code>&gt;&gt;&gt; resp = dev.rpc.request_pfe_execute(target='fpc0', command='show version')
&gt;&gt;&gt; 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
</code></pre>

python junos-automation pyez