ExtremeSwitching (EXOS)

  • 1.  exsh error inside imported file

    Posted 09-23-2016 14:51
    EXOS version 16.1.1.4 I am working on a couple of python scripts. So far everything is working as planned, however I'm getting an error when I try to create multiple files that can be imported (instead of one big file). Below I will give 2 example files and the error that I'm getting. Example File Name: ImportedFile.py def showVlan(): exsh.clicmd('show vlan', xml=True) File Name: main.py import importedFile if __name__ == '__main__': importedFile.showVlan() Both files are in /usr/local/cfg. When I run main.py I get the following error: Slot-1.21 # run script main.py Traceback (most recent call last): File "/config/main.py", line 6, in importedFile.showVlan() File "/config/importedFile.py", line 4, in showVlan exsh.clicmd('show vlan', xml=True) NameError: global name 'exsh' is not defined Is it not possible to run exsh from an imported file?


  • 2.  RE: exsh error inside imported file

    Posted 09-23-2016 15:17
    You will have to add:
    import exsh[/code]to ImportedFile.py

    exsh is automatically included in the file specified by run script file.py,
    but must be explicitly imported beyond that.


  • 3.  RE: exsh error inside imported file

    Posted 09-23-2016 19:31
    I think you need to define a variable that can store the output of the command output, otherwise where does all that output go when it is retrieved?
    variable = exsh.clicmd(


  • 4.  RE: exsh error inside imported file

    Posted 10-06-2016 14:00
    @Dave Hammers Sorry for the late reply, but the import is what I was missing. Didn't know it was explicitly imported.