Procedure
Login to your switch
Use VI to create a python script, or use TFTP to transfer the Python file to EXOS.
Type vi <Python_FILE_NAME>.py to create the Python file
In the Vi editor, type press the i key to enter insert mode.
Create the Python script.
Exit insert mode by pressing the Esc key.
Save and exit by typing :wq
Run your Python script.
To run the script use the command load script <Python_FILE_NAME>.py
Example:
# vi chg_mask.py
import exsh
exsh.clicmd(“unconfigure vlan MGMT ipaddress”)
exsh.clicmd(“configure vlan MGMT ipaddress 10.10.10.130 255.255.255.192”)
print (“Change complete!”)
# cat chg_mask.py
import exsh
exsh.clicmd(“unconfigure vlan MGMT ipaddress”)
exsh.clicmd(“configure vlan MGMT ipaddress 10.10.10.130 255.255.255.192”)
print (“Change complete!”)
# load sc chg_mask.py
Note: Used this on a live switch and changed the mask remotely without losing connection. Existing SSH session stayed connected which is why I scripted it, in case doing this procedure one line at a time without a script would cut me off.