08-04-2022 09:42 AM
xxxx-SW1.8 # cat test.py
print ("Script Start!")
for number in range(1,11):
print ("The number count is {0}").format(number)
showvlan = exsh.clicmd("show vlan", True)
print showvlan
xxxx-SW1.9 # load script test.py
Script Start!
The number count is 1
The number count is 2
The number count is 3
The number count is 4
The number count is 5
The number count is 6
The number count is 7
The number count is 8
The number count is 9
The number count is 10
Traceback (most recent call last):
File "/usr/local/cfg/test.py", line 5, in <module>
showvlan = exsh.clicmd("show vlan", True)
NameError: name 'exsh' is not defined
Does the X435 support Phyton scripting?
Solved! Go to Solution.
08-04-2022 11:52 AM
import exsh
#before importing the module
X435-8P-2T-W.8 # run script test
Script Start!
The number count is 1
The number count is 2
The number count is 3
The number count is 4
The number count is 5
The number count is 6
The number count is 7
The number count is 8
The number count is 9
The number count is 10
Traceback (most recent call last):
File "/usr/local/cfg/test.py", line 5, in <module>
showvlan = exsh.clicmd("show vlan", True)
NameError: name 'exsh' is not defined
#after importing the module
* X435-8P-2T-W.9 # vi test.py
* X435-8P-2T-W.10 # run script test
Script Start!
The number count is 1
The number count is 2
The number count is 3
The number count is 4
The number count is 5
The number count is 6
The number count is 7
The number count is 8
The number count is 9
The number count is 10
Untagged ports auto-move: Inform
-----------------------------------------------------------------------------------------------
Name VID Protocol Addr Flags Proto Ports Virtual
Active router
/Total
-----------------------------------------------------------------------------------------------
Default 1 10.67.72.83 /24 ------------T------------- ANY 2 /10 VR-Default
-----------------------------------------------------------------------------------------------
Flags : (B) BFD Enabled, (c) 802.1ad customer VLAN, (C) EAPS Control VLAN,
(d) Dynamically created VLAN, (D) VLAN Admin Disabled,
(E) ESRP Enabled, (f) IP Forwarding Enabled,
(F) Learning Disabled, (i) ISIS Enabled,
(I) Inter-Switch Connection VLAN for MLAG, (k) PTP Configured,
(l) MPLS Enabled, (L) Loopback Enabled, (m) IPmc Forwarding Enabled,
(M) Translation Member VLAN or Subscriber VLAN, (n) IP Multinetting Enabled,
(N) Network Login VLAN, (o) OSPF Enabled, (O) Virtual Network Overlay,
(p) PIM Enabled, (P) EAPS protected VLAN, (r) RIP Enabled,
(R) Sub-VLAN IP Range Configured, (s) Sub-VLAN, (S) Super-VLAN,
(t) Translation VLAN or Network VLAN, (T) Member of STP Domain,
(v) VRRP Enabled, (V) VPLS Enabled, (W) VPWS Enabled,
(Y) Policy Enabled
Total number of VLAN(s) : 1
Below is more information on Python and EXOS:
https://documentation.extremenetworks.com/pdfs/exos/Python_Getting_Started_Guide.pdf
08-08-2022 09:20 AM
08-05-2022 03:49 AM
Hello Christopher, Thank you for your reply. It works now.
Python Getting Started Guide - that guide is awesome!
08-04-2022 12:00 PM
08-04-2022 11:52 AM
import exsh
#before importing the module
X435-8P-2T-W.8 # run script test
Script Start!
The number count is 1
The number count is 2
The number count is 3
The number count is 4
The number count is 5
The number count is 6
The number count is 7
The number count is 8
The number count is 9
The number count is 10
Traceback (most recent call last):
File "/usr/local/cfg/test.py", line 5, in <module>
showvlan = exsh.clicmd("show vlan", True)
NameError: name 'exsh' is not defined
#after importing the module
* X435-8P-2T-W.9 # vi test.py
* X435-8P-2T-W.10 # run script test
Script Start!
The number count is 1
The number count is 2
The number count is 3
The number count is 4
The number count is 5
The number count is 6
The number count is 7
The number count is 8
The number count is 9
The number count is 10
Untagged ports auto-move: Inform
-----------------------------------------------------------------------------------------------
Name VID Protocol Addr Flags Proto Ports Virtual
Active router
/Total
-----------------------------------------------------------------------------------------------
Default 1 10.67.72.83 /24 ------------T------------- ANY 2 /10 VR-Default
-----------------------------------------------------------------------------------------------
Flags : (B) BFD Enabled, (c) 802.1ad customer VLAN, (C) EAPS Control VLAN,
(d) Dynamically created VLAN, (D) VLAN Admin Disabled,
(E) ESRP Enabled, (f) IP Forwarding Enabled,
(F) Learning Disabled, (i) ISIS Enabled,
(I) Inter-Switch Connection VLAN for MLAG, (k) PTP Configured,
(l) MPLS Enabled, (L) Loopback Enabled, (m) IPmc Forwarding Enabled,
(M) Translation Member VLAN or Subscriber VLAN, (n) IP Multinetting Enabled,
(N) Network Login VLAN, (o) OSPF Enabled, (O) Virtual Network Overlay,
(p) PIM Enabled, (P) EAPS protected VLAN, (r) RIP Enabled,
(R) Sub-VLAN IP Range Configured, (s) Sub-VLAN, (S) Super-VLAN,
(t) Translation VLAN or Network VLAN, (T) Member of STP Domain,
(v) VRRP Enabled, (V) VPLS Enabled, (W) VPWS Enabled,
(Y) Policy Enabled
Total number of VLAN(s) : 1
Below is more information on Python and EXOS:
https://documentation.extremenetworks.com/pdfs/exos/Python_Getting_Started_Guide.pdf