08-03-2015 05:02 AM
Hey guys,
could someone provide me (not sure if it`s even possible with tcl) a script which changes the hostname of a device from upper case to lower case letters?
The hostname always consits of 5 letters and 3 numbers. e.g ABCDE012
And the script should change it to abcde012.
My goal is to roll it out with a NMS on about ~100 switches.
Thank you in advance!
Solved! Go to Solution.
08-03-2015 09:19 AM
The Tcl code to do this is rather simple:
set hostname [string tolower $hostname]
Then, if it's tclsh you're using:
ios_config "hostname $hostname"
08-03-2015 09:19 AM
The Tcl code to do this is rather simple:
set hostname [string tolower $hostname]
Then, if it's tclsh you're using:
ios_config "hostname $hostname"
08-04-2015 03:47 AM
Hi Joseph,
thank you for the quick response!
Do i have to run this as a event manager applet or how can i execute it?
My Environment:
Hardware: WS-C2960CG-8TC-L
Software: C2960c405ex-UNIVERSALK9-M 15.2(2)E
08-04-2015 09:08 AM
This is tclsh code. Just execute tclsh and paste the code in.
08-05-2015 06:46 AM
Why does it not work? :/
SWITCHNAME#tclsh
SWITCHNAME(tcl)#set hostname [string tolower $hostname]
can't read "hostname": no such variable
SWITCHNAME(tcl)#ios_config "hostname $hostname"
can't read "hostname": no such variable
SWITCHNAME(tcl)#tclquit
SWITCHNAME#
08-05-2015 10:10 AM
I had assumed you already had extracted the hostname into the $hostname variable. But to do that, use:
set hostname [info hostname]
08-05-2015 10:30 PM
Hi Joseph,
okay that makes absolutly sense.
Thank you for the support, it works like a charm!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide