<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to send junos shell command with pyats in Tools</title>
    <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/5006663#M3454</link>
    <description>&lt;P&gt;Where do I request it?&lt;/P&gt;</description>
    <pubDate>Fri, 26 Jan 2024 20:16:26 GMT</pubDate>
    <dc:creator>assadniang</dc:creator>
    <dc:date>2024-01-26T20:16:26Z</dc:date>
    <item>
      <title>How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4944741#M3411</link>
      <description>&lt;P&gt;How do I send a command to the junos shell with pyats&lt;/P&gt;&lt;P&gt;junos&amp;gt;start shell&lt;BR /&gt;junos#cd /var/public&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------&lt;/P&gt;&lt;P&gt;juniper_device = testbed.devices['ptr513-u210']&lt;BR /&gt;juniper_device.connect()&lt;BR /&gt;juniper_device.execute('cd /var/public') &amp;lt;--- this fails&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 07:10:38 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4944741#M3411</guid>
      <dc:creator>assadniang</dc:creator>
      <dc:date>2023-10-20T07:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4944756#M3412</link>
      <description>&lt;P&gt;I think your error is due to&lt;SPAN&gt;&amp;nbsp;command being sent to the wrong CLI mode? Here is an example i found how you can do this.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;You.&lt;SPAN&gt;connect to the Junos device using the PyATS Testbed and Device objects. Once establishing the connection, call the device.shell() method to open the Junos shell. Then, you can send commands to the shell using the device.execute() method, specifying cli_mode='junos' to direct the commands to the Junos shell instead of the default vty shell. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Call device.execute('exit') to exit the Junos shell when you are done running commands. Always disconnect from the device using the disconnect() method to close the connection cleanly. &lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyats.topology import Testbed, Device 

testbed = Testbed('testbed.yaml')
device = testbed.devices['ptr513-u210']
device.connect()

# Open Junos shell
device.shell()

# Send command to Junos shell
device.execute('cd /var/public', cli_mode='junos')

# Exit shell
device.execute('exit', cli_mode='junos')

device.disconnect()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 07:36:50 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4944756#M3412</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2023-10-20T07:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945051#M3413</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/352839"&gt;@bigevilbeard&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I am getting this error message:&lt;BR /&gt;pyats==23.8&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; import yaml&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; from pyats.topology import loader&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; from pyats.topology import Testbed, Device&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; testbed = loader.load('devices.yaml')&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; jdm_device = testbed.devices['ptr513-u210']&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; jdm_device.connect()&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;gt;&amp;gt;&amp;gt; jdm_device.shell()&lt;/STRONG&gt;&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "src/pyats/topology/device.py", line 559, in pyats.topology.device.Device.__getattr__&lt;BR /&gt;AttributeError: 'Device' object has no attribute 'shell'&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 14:11:31 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945051#M3413</guid>
      <dc:creator>assadniang</dc:creator>
      <dc:date>2023-10-20T14:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945056#M3414</link>
      <description>&lt;P&gt;Hmmm i wonder if Juniper&amp;nbsp;&lt;SPAN&gt;device does not support the shell() method in PyATS?&amp;nbsp;&lt;/SPAN&gt;Try&amp;nbsp;&lt;SPAN&gt;adding&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;the line jdm_device.os = 'junos' before connecting, and shell() should work as expected.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;testbed = Testbed('testbed.yaml') 
jdm_device = testbed.devices['ptr513-u210']
jdm_device.os = 'junos'
jdm_device.connect()
jdm_device.shell()&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 20 Oct 2023 14:16:52 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945056#M3414</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2023-10-20T14:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945062#M3415</link>
      <description>&lt;P&gt;Same error message&lt;BR /&gt;The os for that device was already set to junos in .yalm file&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; jdm_device.os = 'junos'&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; jdm_device.connect()&lt;/P&gt;&lt;P&gt;2023-10-20 10:22:04,978: %UNICON-INFO: ptr513-u210 is already connected&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt; jdm_device.shell()&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "src/pyats/topology/device.py", line 559, in pyats.topology.device.Device.__getattr__&lt;BR /&gt;AttributeError: 'Device' object has no attribute 'shell'&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ptr513-u210&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;router&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;STRONG&gt; &amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;os: junos&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;platform: sdwan&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;# &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;alias: 'uut'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;credentials&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;default&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;username&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;root&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;password&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;juniper123&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;connections&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;cli&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;protocol&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;ssh&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ip&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;SPAN&gt;f207:a185:172:30:7::513:1&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 20 Oct 2023 14:25:36 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945062#M3415</guid>
      <dc:creator>assadniang</dc:creator>
      <dc:date>2023-10-20T14:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945099#M3416</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Right, if the OS is already specified as Junos in the testbed YAML file, which would imply shell isnt supported and only&amp;nbsp;works for IOS XE and NXOS in PyATS. Would somthing like this work? (i am not a JUNOS user btw)&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;jdm_device.execute('cli', cli_mode='junos')
jdm_device.execute('show version', cli_mode='junos')
jdm_device.execute('exit', cli_mode='junos')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 15:07:34 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945099#M3416</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2023-10-20T15:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945116#M3417</link>
      <description>&lt;P&gt;That did not work...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; jdm_device.execute('cli', cli_mode='junos')&lt;/P&gt;&lt;P&gt;2023-10-20 11:39:25,294: %UNICON-INFO: +++ ptr513-u210 with via 'cli': executing command 'cli' +++&lt;BR /&gt;cli&lt;BR /&gt;&lt;A href="https://community.cisco.com/" target="_blank"&gt;root@ptr513-u210&amp;gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "src/unicon/bases/routers/services.py", line 259, in unicon.bases.routers.services.BaseService.__call__&lt;BR /&gt;File "/opt/labs-scripts/common-python39-venv/lib64/python3.9/site-packages/unicon/plugins/generic/service_implementation.py", line 730, in call_service&lt;BR /&gt;dialog_match = dialog.process(&lt;BR /&gt;File "src/unicon/eal/dialogs.py", line 476, in unicon.eal.dialogs.Dialog.process&lt;BR /&gt;File "src/unicon/eal/dialog_processor.py", line 321, in unicon.eal.dialog_processor.SimpleDialogProcessor.process&lt;BR /&gt;File "src/unicon/eal/dialog_processor.py", line 235, in unicon.eal.dialog_processor.SimpleDialogProcessor.expect_eval_statements&lt;BR /&gt;File "/opt/labs-scripts/common-python39-venv/lib64/python3.9/site-packages/unicon/plugins/generic/service_implementation.py", line 65, in invalid_state_change_action&lt;BR /&gt;raise StateMachineError(msg)&lt;BR /&gt;unicon.core.errors.StateMachineError: Expected device to reach 'shell' state, but landed on 'enable' state.&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt;&lt;BR /&gt;------------------------------------------------------------------------&lt;BR /&gt;&lt;BR /&gt;I was thinking if we can tell the code to expect (&lt;STRONG&gt;#&lt;/STRONG&gt;) after we send the command, like in netmiko&lt;/P&gt;&lt;P&gt;something like this?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;gt;&amp;gt;&amp;gt; jdm_device.execute('start shell', expect '#')&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;---------------------------------------------------------&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;gt;&amp;gt;&amp;gt; jdm_device.execute('start shell')&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;It enters 'shell' mode (#), but right after it complains that it expect to be in enable mode&lt;/P&gt;&lt;P&gt;&amp;nbsp;2023-10-20 11:29:03,316: %UNICON-INFO: +++ ptr513-u210 with via 'cli': executing command 'start shell' +++&lt;BR /&gt;start shell&lt;BR /&gt;&lt;STRONG&gt;root@ptr513-u210:~ #&lt;/STRONG&gt;&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;File "src/unicon/bases/routers/services.py", line 259, in unicon.bases.routers.services.BaseService.__call__&lt;BR /&gt;File "/opt/labs-scripts/common-python39-venv/lib64/python3.9/site-packages/unicon/plugins/generic/service_implementation.py", line 730, in call_service&lt;BR /&gt;dialog_match = dialog.process(&lt;BR /&gt;File "src/unicon/eal/dialogs.py", line 476, in unicon.eal.dialogs.Dialog.process&lt;BR /&gt;File "src/unicon/eal/dialog_processor.py", line 321, in unicon.eal.dialog_processor.SimpleDialogProcessor.process&lt;BR /&gt;File "src/unicon/eal/dialog_processor.py", line 235, in unicon.eal.dialog_processor.SimpleDialogProcessor.expect_eval_statements&lt;BR /&gt;File "/opt/labs-scripts/common-python39-venv/lib64/python3.9/site-packages/unicon/plugins/generic/service_implementation.py", line 65, in invalid_state_change_action&lt;BR /&gt;raise StateMachineError(msg)&lt;BR /&gt;&lt;STRONG&gt;unicon.core.errors.StateMachineError: Expected device to reach 'enable' state, but landed on 'shell' state.&lt;/STRONG&gt;&lt;BR /&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 15:42:46 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/4945116#M3417</guid>
      <dc:creator>assadniang</dc:creator>
      <dc:date>2023-10-20T15:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/5006578#M3452</link>
      <description>&lt;P&gt;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/352839"&gt;@bigevilbeard&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I request this feature to be added to the next release of PyATS for Junos?&lt;BR /&gt;&lt;SPAN&gt;To be able to go into Junos Shell and execute some commands&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 17:37:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/5006578#M3452</guid>
      <dc:creator>assadniang</dc:creator>
      <dc:date>2024-01-26T17:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/5006660#M3453</link>
      <description>&lt;P&gt;I’m sure you can request this, yes.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 20:13:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/5006660#M3453</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2024-01-26T20:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/5006663#M3454</link>
      <description>&lt;P&gt;Where do I request it?&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 20:16:26 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/5006663#M3454</guid>
      <dc:creator>assadniang</dc:creator>
      <dc:date>2024-01-26T20:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to send junos shell command with pyats</title>
      <link>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/5006933#M3455</link>
      <description>&lt;P&gt;I am guessing Email&amp;nbsp;&lt;A style="font-family: inherit; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;" href="mailto:pyats-support-ext%40cisco.com" target="_blank"&gt;pyats-support-ext@cisco.com &lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jan 2024 08:04:03 GMT</pubDate>
      <guid>https://community.cisco.com/t5/tools/how-to-send-junos-shell-command-with-pyats/m-p/5006933#M3455</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2024-01-27T08:04:03Z</dc:date>
    </item>
  </channel>
</rss>

