ExtremeSwitching (EXOS)

  • 1.  EOS Scripting Issue - (TCL)

    Posted 05-08-2014 22:10
    I am in the process of writing an XOS script to backup switches on a UPM event and also ad-hoc by executing the xsf file stored on the switches.
    The below code is what I have issues with so far.

    # Get config selected filename
    set var cli.out 0
    show switch
    set var sh_sw_output $tcl(split ${cli.out} "\n")
    set var sh_sw_index $tcl(lindex $sh_sw_output 24)
    set var config_selected $tcl(string replace $sh_sw_index 0 17 {})
    #Get switch name
    set var sh_sw_output $tcl(split ${cli.out} "\n")
    set var sh_sw_index $tcl(lindex $sh_sw_output 1)
    set var switch_name_raw $tcl(string replace $sh_sw_index 0 17 {})
    #Change spaces to underscore
    set var switch_name $tcl(regsub -all {\W} $switch_name_raw "_" {})
    show var config_selected
    show var switch_name

    Basically when i am trying to replace spaces with underscores with "set var switch_name $tcl(regsub -all {\W} $switch_name_raw "_" {})" it is not actually returning the variable with spaces replaced with underscores it is returning the number of times it matched the regex.

    EG if the switch name was "Test Scripting Switch" the variable switch_name would be "2" not "Test_Scripting_Switch"

    Any ideas ?



  • 2.  RE: EOS Scripting Issue - (TCL)

    Posted 05-09-2014 03:04
    All fixed.

    For anyone interested I used the following to convert spaces to underscores.

    set var switch_name $tcl(join [split $switch_name_raw " "] "_")