Juniper / py-junos-eznc

Python library for Junos automation
https://www.juniper.net/documentation/en_US/junos-pyez/information-products/pathway-pages/junos-pyez-developer-guide.html
Apache License 2.0
671 stars 344 forks source link

PYEZ on VTY SHELL on PTX5K platform - Syntax error at 'echo' #1158

Closed georgjackson closed 2 years ago

georgjackson commented 2 years ago

We are testing Python script with PYEZ on PTX5k platform. Could you please help if you know what can cause this behavior ?

What I noticed if I execute same command in the loop – sometimes I am getting response and sometimes Syntax error at `echo'.

def execution(): with StartShell(dev) as ss: ss.run('vty fpc0') time.sleep(1) with open('/Users/dbalyura/Downloads/testtest.txt', 'a+') as my_file: for x in range(0,3): print ss.run('show version'.format(x))[1]

my_file.write(aaa[1])

            time.sleep(1)

Example of loop of 3 times:

1 show version

Juniper Embedded Microkernel Version 21.4R1.2 Built by builder on 2021-11-11 06:09:45 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (1750Mhz Intel(R) Atom(TM) CPU processor, 3072MB memory, 8192KB flash) Current time : Feb 23 00:11:12.7013 Elapsed time : 85+03:46:49

GLDFPC3T0(DUT-PTX5K-re0 vty)#

2 show version

Juniper Embedded Microkernel Version 21.4R1.2 Built by builder on 2021-11-11 06:09:45 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (1750Mhz Intel(R) Atom(TM) CPU processor, 3072MB memory, 8192KB flash) Current time : Feb 23 00:11:13.185438 Elapsed time : 85+03:46:50

GLDFPC3T0(DUT-PTX5K-re0 vty)#

3 – 3rd times it returned an error, and it is always random ^ Syntax error at `echo'.

GLDFPC3T0(DUT-PTX5K-re0 vty)# echo ^ Syntax error at `echo'.

GLDFPC3T0(DUT-PTX5K-re0 vty)#

Process finished with exit code 0

chidanandpujar commented 2 years ago

Hi ,

            Please check if following option works fine ,since  vty fpc0 does not support the shell commands .
            I have executed the command in a loop of 10 iterations ,it works fine .

from jnpr.junos import Device

with Device(host='xx.xx.xx.xx', user='xyz', password='xyz') as dev: for x in range(0,10): print (dev.cli('', warning=False))

pyez_debug$ python3 test_vty2.py

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 18:59:53.136134 Elapsed time : 2+08:49:12

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 19:00:00.383348 Elapsed time : 2+08:49:19

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 19:00:07.611898 Elapsed time : 2+08:49:26

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 19:00:14.841298 Elapsed time : 2+08:49:33

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 19:00:22.117379 Elapsed time : 2+08:49:41

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 19:00:29.472640 Elapsed time : 2+08:49:48

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 19:00:36.696144 Elapsed time : 2+08:49:55

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 19:00:43.925578 Elapsed time : 2+08:50:02

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 19:00:51.152192 Elapsed time : 2+08:50:10

SENT: Ukern command: show version

Juniper Embedded Microkernel Version 21.4R1.4 Built by builder on 2021-11-19 02:36:30 UTC Copyright (C) 1998-2021, Juniper Networks, Inc. All rights reserved.

GLDFPC platform (2300Mhz Intel(R) Atom(TM) CPU processor, 1792MB memory, 8192KB flash) Current time : Feb 25 19:00:58.466459 Elapsed time : 2+08:50:17

Thanks & Regards Chidanand

chidanandpujar commented 2 years ago

Please feel free to re-open the issue ,if above solution does not work .

Thanks & Regards Chidanand