<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic RE: Netsight TCL Scripting - Modifying Switch Banners in ExtremeCloud IQ- Site Engine Management Center</title>
    <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35219#M3989</link>
    <description>oh, and btw, starting with EMC 8.0.4 you have access to Python scripting too. I tested the dirty trick on an EXOS VM with Python.&lt;BR /&gt;</description>
    <pubDate>Fri, 27 Oct 2017 01:27:00 GMT</pubDate>
    <dc:creator>Stephane_Grosj1</dc:creator>
    <dc:date>2017-10-27T01:27:00Z</dc:date>
    <item>
      <title>Netsight TCL Scripting - Modifying Switch Banners</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35217#M3987</link>
      <description>I want to be able to make modifications to the after-login banner on my 4,000 switches. I would like to use a TCL script from within Netsight to do it.&lt;BR /&gt;
&lt;BR /&gt;
I have the entire script working except that I found that the "configure banner" command is uniquely problematic. The command needs to be issued and then the text of the banner typed out in a terminal and finished with a blank line to denote the end of the banner.&lt;BR /&gt;
&lt;BR /&gt;
The problem within a script is that when I issue the "configure banner after-login" command, there is no response of any kind from the switch. I want to be able to send the text of the banner, and I thought I could do it with:&lt;BR /&gt;
&lt;BR /&gt;
CLI $bannerText&lt;BR /&gt;
&lt;BR /&gt;
but that just times out.&lt;BR /&gt;
&lt;BR /&gt;
In other situations where further input is required the idiom is typically:&lt;BR /&gt;
&lt;BR /&gt;
SAVE config secondary&lt;BR /&gt;
 regexp {.*overwrite it?.*} ${CLI.OUT} foundit&lt;BR /&gt;
  IF ([info exists foundit]) THEN&lt;BR /&gt;
   CLI yes&lt;BR /&gt;
  ENDIF &lt;BR /&gt;
So you issue a command and match on the CLI.OUT contents.&lt;BR /&gt;
&lt;BR /&gt;
In this case it seems like the script just hangs on the banner command and times out.&lt;BR /&gt;
&lt;BR /&gt;
JUST WONDERING IF ANYBODY HAS FOUND A WAY AROUND THIS.&lt;BR /&gt;
I have a TCL script outside of Netsight that can do this but it's much better to allow all my colleagues to run the script from inside our management system.</description>
      <pubDate>Thu, 26 Oct 2017 20:23:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35217#M3987</guid>
      <dc:creator>Ed_McGuigan1</dc:creator>
      <dc:date>2017-10-26T20:23:00Z</dc:date>
    </item>
    <item>
      <title>RE: Netsight TCL Scripting - Modifying Switch Banners</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35218#M3988</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I haven't found a way about that command, and asking around, still haven't found someone with a solution neither. Not sure this is achievable. I can think of a dirty trick, but that's not great: the command will be taken in account, and the timeout will work as that blank line so... just do a script for the banner with a very short timeout.&lt;BR /&gt;
&lt;BR /&gt;
Ugly, yes, just as I said &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Oct 2017 01:27:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35218#M3988</guid>
      <dc:creator>Stephane_Grosj1</dc:creator>
      <dc:date>2017-10-27T01:27:00Z</dc:date>
    </item>
    <item>
      <title>RE: Netsight TCL Scripting - Modifying Switch Banners</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35219#M3989</link>
      <description>oh, and btw, starting with EMC 8.0.4 you have access to Python scripting too. I tested the dirty trick on an EXOS VM with Python.&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Oct 2017 01:27:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35219#M3989</guid>
      <dc:creator>Stephane_Grosj1</dc:creator>
      <dc:date>2017-10-27T01:27:00Z</dc:date>
    </item>
    <item>
      <title>RE: Netsight TCL Scripting - Modifying Switch Banners</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35220#M3990</link>
      <description>Thanks Stephane. I haven't seen much documentation on the Python scripting but I certainly want to give it a go - want to learn Python anyway ( I know Perl and I learned TCL for the Extreme environment )&lt;BR /&gt;
&lt;BR /&gt;
I found that even when my script timed out, I wasn't completing the banner command.&lt;BR /&gt;
I couldn't find a method of sending the command plus the banner text at the switch. Assuming I had a string with the command and banner text in it, how would I use it to issue the command to the switch?&lt;BR /&gt;
&lt;BR /&gt;
I tried:&lt;BR /&gt;
&lt;BR /&gt;
configure banner after-login $bannerTextWithLeadingNewline&lt;BR /&gt;
&lt;BR /&gt;
but that didn't seem to work ( maybe I missed the trailing blank line and newline ? )&lt;BR /&gt;
&lt;BR /&gt;
There seems to be a command like:&lt;BR /&gt;
&lt;BR /&gt;
CLI $string&lt;BR /&gt;
&lt;BR /&gt;
but I can't find documentation beyond its use in some sample scripts.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help with this BTW.&lt;BR /&gt;
&lt;BR /&gt;
Ed.</description>
      <pubDate>Fri, 27 Oct 2017 01:27:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35220#M3990</guid>
      <dc:creator>Ed_McGuigan1</dc:creator>
      <dc:date>2017-10-27T01:27:00Z</dc:date>
    </item>
    <item>
      <title>RE: Netsight TCL Scripting - Modifying Switch Banners</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35221#M3991</link>
      <description>ah, documentation... Python scripting is very new with 8.0.4.&lt;BR /&gt;
&lt;BR /&gt;
quickly:&lt;BR /&gt;
&lt;BR /&gt;
- emc_vars : this is a dictionary with all the regular TCL variables&lt;BR /&gt;
&lt;BR /&gt;
ex: myVar = emc_vars["deviceIP"]&lt;BR /&gt;
&lt;BR /&gt;
to trigger port selection from the user:&lt;BR /&gt;
&lt;BR /&gt;
ports = emc_vars["port"]&lt;BR /&gt;
&lt;BR /&gt;
- emc_cli : to send command and have the output.&lt;BR /&gt;
&lt;BR /&gt;
cli_results = emc_cli.send("show vlan")&lt;BR /&gt;
cli_output = cli_results.getOutput()&lt;BR /&gt;
&lt;BR /&gt;
1st line is the command itself&lt;BR /&gt;
then the output&lt;BR /&gt;
last line is the prompt&lt;BR /&gt;
&lt;BR /&gt;
you may want to get rid of that:&lt;BR /&gt;
&lt;BR /&gt;
'\n'.join(cli_output.splitlines()[1:-1])&lt;BR /&gt;
&lt;BR /&gt;
---&lt;BR /&gt;
&lt;BR /&gt;
for your need, I simply tested on an EXOS VM (22.2) a simple script like that:&lt;BR /&gt;
&lt;BR /&gt;
emc_cli.send("config banner after-login")&lt;BR /&gt;
emc_cli.send("this is a banner")&lt;BR /&gt;
&lt;BR /&gt;
still a dirty trick, but if it works and helps...&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Oct 2017 01:27:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35221#M3991</guid>
      <dc:creator>Stephane_Grosj1</dc:creator>
      <dc:date>2017-10-27T01:27:00Z</dc:date>
    </item>
    <item>
      <title>RE: Netsight TCL Scripting - Modifying Switch Banners</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35222#M3992</link>
      <description>Embarrassingly I found that I had made a mistake and hadn't put a double newline at the end of my banner text:&lt;BR /&gt;
&lt;BR /&gt;
   # Join list into one big string&lt;BR /&gt;
   set var myBanner [ join $lineList "\n" ]&lt;BR /&gt;
   # prefix with newline and suffix with two&lt;BR /&gt;
   &lt;B&gt;set var myBanner "\n$myBanner\n\n"&lt;/B&gt;&lt;BR /&gt;
   # Issue command&lt;BR /&gt;
   configure banner after-login $myBannerThat worked a treat. Just needed to step away from the problem. Pasted script here in case anybody cares to look at it. Maybe there are some helpful tcl examples for total novices:&lt;BR /&gt;
&lt;BR /&gt;
#@MetaDataStart&lt;BR /&gt;
#@DetailDescriptionStart&lt;BR /&gt;
#############################################################################&lt;BR /&gt;
# Extreme Networks(R) CLI Scripting Library&lt;BR /&gt;
#&lt;BR /&gt;
# Script        : Logbook URL Insertion - After Banner&lt;BR /&gt;
# Revision      : 1.0&lt;BR /&gt;
# Last Updated  : Nov 1 2017&lt;BR /&gt;
#&lt;BR /&gt;
# When work is performed on a switch that relates to some unique circumstance&lt;BR /&gt;
# on that switch, it is important to be able to keep a record of that work&lt;BR /&gt;
# and for that work to be accessible to other technicians. The process is to &lt;BR /&gt;
# establish a google sites page for a whole location or possibly a single switch&lt;BR /&gt;
# and to include a shortened URL in the after login banner for the switch&lt;BR /&gt;
# ( there is a limit of 80 characters on banner lines so full URLs get tricky )&lt;BR /&gt;
#&lt;BR /&gt;
# The workflow is as follows:&lt;BR /&gt;
# - issue arises on a device that warrants some custom action ( port turned down, trap suppressed )&lt;BR /&gt;
# - establish a Sites page under the URL &lt;A href="https://sites.google.com/a/*****/extremenetworking/home/devicehistories" target="_blank" rel="nofollow noreferrer noopener"&gt;https://sites.google.com/a/*****/extremenetworking/home/devicehistories&lt;/A&gt;&lt;BR /&gt;
#   for the specific location ( e.g. CrystalLakesES )&lt;BR /&gt;
# - document the issue and action taken against the device ( see example at &lt;A href="https://sites.google.com/a/*****/extremenetworking/home/devicehistories/devices254" target="_blank" rel="nofollow noreferrer noopener"&gt;https://sites.google.com/a/*****/extremenetworking/home/devicehistories/devices254&lt;/A&gt; )&lt;BR /&gt;
# - shortent the URL for the new page using the Google service &lt;A href="https://goo.gl/" target="_blank" rel="nofollow noreferrer noopener"&gt;https://goo.gl/&lt;/A&gt;&lt;BR /&gt;
# - Insert the short URL at the bottom of the login banner with this script.&lt;BR /&gt;
#&lt;BR /&gt;
#####################################################################&lt;BR /&gt;
#@DetailDescriptionEnd&lt;BR /&gt;
#############################################################################################&lt;BR /&gt;
# Define identity management configuration parameters in this section.&lt;BR /&gt;
#############################################################################################&lt;BR /&gt;
#&lt;B&gt;@SectionStart&lt;/B&gt; (description = Script configuration properties)&lt;BR /&gt;
&lt;BR /&gt;
#&lt;B&gt;@VariableFieldLabel&lt;/B&gt; (description     = "Stop on error?"&lt;BR /&gt;
#     type            = String,&lt;BR /&gt;
#     scope           = global,&lt;BR /&gt;
#     required      = yes,&lt;BR /&gt;
#     validValues=[yes,no])&lt;BR /&gt;
set var abort_when_error yes&lt;BR /&gt;
&lt;BR /&gt;
#&lt;B&gt;@VariableFieldLabel&lt;/B&gt; ( description = "tinyURL",&lt;BR /&gt;
#    type      = String,&lt;BR /&gt;
#   scope      = global,&lt;BR /&gt;
#   required   = yes,&lt;BR /&gt;
#   readonly   = no&lt;BR /&gt;
#)&lt;BR /&gt;
set var tinyURL &lt;A href="https://itssotiny" target="_blank" rel="nofollow noreferrer noopener"&gt;https://itssotiny&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
#&lt;B&gt;@VariableFieldLabel&lt;/B&gt; ( description = "urlSeparator",&lt;BR /&gt;
#    type      = String,&lt;BR /&gt;
#   scope      = global,&lt;BR /&gt;
#   required   = yes,&lt;BR /&gt;
#   readonly   = no&lt;BR /&gt;
#)&lt;BR /&gt;
set var urlSeparator =LBU==========================================================================&lt;BR /&gt;
&lt;BR /&gt;
#&lt;B&gt;@VariableFieldLabel&lt;/B&gt; ( description = "urlBody",&lt;BR /&gt;
#    type      = String,&lt;BR /&gt;
#   scope      = global,&lt;BR /&gt;
#   required   = yes,&lt;BR /&gt;
#   readonly   = no&lt;BR /&gt;
#)&lt;BR /&gt;
set var urlBody "Logbook URL:"&lt;BR /&gt;
&lt;BR /&gt;
#&lt;B&gt;@SectionEnd&lt;/B&gt;&lt;BR /&gt;
&lt;BR /&gt;
#&lt;B&gt;@MetaDataEnd&lt;/B&gt;&lt;BR /&gt;
##################################################################&lt;BR /&gt;
# TCL Procedure for Changing MIB View&lt;BR /&gt;
##################################################################&lt;BR /&gt;
proc addURL {&lt;BR /&gt;
  tinyURL&lt;BR /&gt;
  urlSeparator&lt;BR /&gt;
  urlBody&lt;BR /&gt;
      } {     &lt;BR /&gt;
   set var urlText "$urlSeparator$urlBody$tinyURL$urlSeparator"&lt;BR /&gt;
   set var CLI.OUT 0&lt;BR /&gt;
   show banner after-login&lt;BR /&gt;
   set var lineList [ split ${CLI.OUT} "\n" ]&lt;BR /&gt;
   # The last value in the list is the switch login prompt so it needs&lt;BR /&gt;
   # to be chopped off&lt;BR /&gt;
   set var lineList [ lreplace $lineList end end ]&lt;BR /&gt;
   delete var CLI.OUT&lt;BR /&gt;
   set var bannerLen [ llength $lineList ]&lt;BR /&gt;
   &lt;BR /&gt;
   # Now need to filter out any lines of output that are not really part of the banner&lt;BR /&gt;
   # First split the lines into a list&lt;BR /&gt;
   set var newBannerList [ list ]&lt;BR /&gt;
   set var startCopying 0&lt;BR /&gt;
   foreach line $lineList {&lt;BR /&gt;
   IF ( $TCL(regexp {After-Login} $line isFound) ) THEN  &lt;BR /&gt;
  set var startCopying 1&lt;BR /&gt;
  continue&lt;BR /&gt;
   ENDIF&lt;BR /&gt;
   IF ( $startCopying == 1 ) THEN&lt;BR /&gt;
      # start copy lines into the new location&lt;BR /&gt;
   lappend newBannerList $line&lt;BR /&gt;
   ENDIF&lt;BR /&gt;
   }&lt;BR /&gt;
   # Now we don't know if we have a URL section in the banner or not&lt;BR /&gt;
   # We need to remove any existing URL section&lt;BR /&gt;
   # Write the remaining lines back into lineList&lt;BR /&gt;
   set var lineList $newBannerList&lt;BR /&gt;
   set var newBannerList [ list ]&lt;BR /&gt;
   set var urlStartIndex 0&lt;BR /&gt;
   set var urlEndIndex 0&lt;BR /&gt;
   set var listIndex 0&lt;BR /&gt;
   foreach line $lineList {&lt;BR /&gt;
     IF ( $urlStartIndex == 0 ) THEN&lt;BR /&gt;
      IF ( [ regexp {^=LBU} $line isFound ] ) THEN&lt;BR /&gt;
      set var urlStartIndex $listIndex&lt;BR /&gt;
   ENDIF&lt;BR /&gt;
   ELSE&lt;BR /&gt;
         IF ( $urlEndIndex == 0 ) THEN&lt;BR /&gt;
         IF ( [ regexp {^=LBU} $line isFound ] ) THEN&lt;BR /&gt;
         set var urlEndIndex $listIndex&lt;BR /&gt;
      ENDIF      &lt;BR /&gt;
         ENDIF&lt;BR /&gt;
   ENDIF&lt;BR /&gt;
      set var listIndex [ expr $listIndex + 1 ]&lt;BR /&gt;
   }&lt;BR /&gt;
   # Replace current URL entry in banner&lt;BR /&gt;
   IF ( $urlStartIndex != 0 &amp;amp;&amp;amp; $urlEndIndex != 0 ) THEN&lt;BR /&gt;
      set var lineList [ lreplace $lineList $urlStartIndex $urlEndIndex $urlSeparator $urlBody $tinyURL $urlSeparator ]&lt;BR /&gt;
   ELSE&lt;BR /&gt;
      # Assume there was no previous URL block in the banner so insert before blank line at list end&lt;BR /&gt;
      set var lineList [ linsert $lineList end-1 $urlSeparator $urlBody $tinyURL $urlSeparator ]&lt;BR /&gt;
   ENDIF&lt;BR /&gt;
   # Join list into one big string&lt;BR /&gt;
   set var myBanner [ join $lineList "\n" ]&lt;BR /&gt;
   # prefix with newline and suffix with two&lt;BR /&gt;
   set var myBanner "\n$myBanner\n\n"&lt;BR /&gt;
   # Issue command&lt;BR /&gt;
   configure banner after-login $myBanner&lt;BR /&gt;
   saveToPrimary "Logbook URL:"&lt;BR /&gt;
   return&lt;BR /&gt;
}&lt;BR /&gt;
#############################################################################&lt;BR /&gt;
# TCL Procedure for CLI Script Execution Mode setting&lt;BR /&gt;
############################################################################&lt;BR /&gt;
proc setCliErrorHandling {inAbortStatus} {&lt;BR /&gt;
     global abort_when_error&lt;BR /&gt;
&lt;BR /&gt;
     if {![string compare $inAbortStatus "yes"]} {&lt;BR /&gt;
        configure cli mode scripting abort-on-error&lt;BR /&gt;
     } else {&lt;BR /&gt;
        configure cli mode scripting ignore-error&lt;BR /&gt;
     }&lt;BR /&gt;
}&lt;BR /&gt;
############################################################################&lt;BR /&gt;
# TCL Procedure for CLI Script Execution Mode setting&lt;BR /&gt;
############################################################################&lt;BR /&gt;
proc saveToPrimary { logSource } { &lt;BR /&gt;
  create log entry "$logSource Saving configuration to primary"&lt;BR /&gt;
  save configuration primary&lt;BR /&gt;
  # handle prompt: Do you want to save configuration to secondary.cfg and overwrite it?    &lt;BR /&gt;
  # CLI.OUT system variable has response of the previous CLI command (SAVe config secondary)&lt;BR /&gt;
  # use regex to check if it is prompt, supply response if found&lt;BR /&gt;
  set var CLI.OUT 0&lt;BR /&gt;
  regexp {.*overwrite it?.*} ${CLI.OUT} foundit&lt;BR /&gt;
  IF ([info exists foundit]) THEN&lt;BR /&gt;
   CLI y&lt;BR /&gt;
  ENDIF&lt;BR /&gt;
  delete var CLI.OUT&lt;BR /&gt;
  create log entry "$logSource Saved configuration to primary"&lt;BR /&gt;
 }&lt;BR /&gt;
 ############################################################################&lt;BR /&gt;
enable cli scripting&lt;BR /&gt;
# enable cli scripting output&lt;BR /&gt;
setCliErrorHandling $abort_when_error&lt;BR /&gt;
addURL $tinyURL $urlSeparator $urlBody&lt;BR /&gt;
disable cli scripting&lt;BR /&gt;
&lt;BR /&gt;</description>
      <pubDate>Thu, 02 Nov 2017 01:19:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35222#M3992</guid>
      <dc:creator>Ed_McGuigan1</dc:creator>
      <dc:date>2017-11-02T01:19:00Z</dc:date>
    </item>
    <item>
      <title>RE: Netsight TCL Scripting - Modifying Switch Banners</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35223#M3993</link>
      <description>Thanks for sharing!&lt;BR /&gt;</description>
      <pubDate>Thu, 02 Nov 2017 01:19:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/netsight-tcl-scripting-modifying-switch-banners/m-p/35223#M3993</guid>
      <dc:creator>Drew_C</dc:creator>
      <dc:date>2017-11-02T01:19:00Z</dc:date>
    </item>
  </channel>
</rss>

