VanDyke Software Forums

VanDyke Software Forums (
-   Scripting (
-   -   Massive Hostname Change (

ruben.dario 06-20-2017 10:03 AM

Massive Hostname Change

The main reason I am using SecureCRT is because I need to change the hostname (and interface descriptions) for over more than 5000+ Cisco routers/switches in a practical and "fast" way.

It seems that the best method for completing this task is using the VanDyke's example script "RunCommandsOnMultipleHostsAndLogResults.vbs" which allows to connect to a list of IP Addresses (or hostnames) and run a list of commands. However this list of commands (in my case) must be unique for each IP address, due the configuration of different hostnames. That is, executing a unique set of commands suck as #hostname HOSTA, for IP_1; then #hostname HOSTB, for IP_2 and so on...

If you have any suggestion for this requirement, I will be more than grateful.

Many thanks in advance,

Ruben D. Colmenares

bgagnon 06-20-2017 10:59 AM

Hi Ruben,

I think "fast" may be a subjective term in this case. :)

If I understand correctly what you are saying, you are going to need 5000 separate ##commands_variable.txt files, correct?

Have you done any of the setup so far?

If so, is any part of the specific entry in the ##hosts.txt file used to identify the specific "commands filename"?

ruben.dario 06-20-2017 11:31 AM

Hey Brenda!

Indeed, maybe "fast" was incorrectly used. What I meant, was to look a more efficient way through SecureCRT rather updating each NE's hostname manually.

Answering your first question, Yes. I'd need a specific configuration file for each router/switch; considering that each hostname will be different.

For the hosts.txt file, I'll have something like this:

Then, the commands to execute:


So as you can see there is no specification of the configuration command script in the hostname files.


bgagnon 06-20-2017 11:48 AM

Hi Ruben,

Are you saying in the commands file, only that one command differs from host to host?

Do you want to be prompted to provide NEW_HOSTNAME?

If not, is there some sort of pattern so it can be automated?

Can you list the explicit steps of how you would do this manually?

If the list contains sensitive data, please send an email to and include "Attn Brenda - Forum Thread #12733" in the subject line.

ruben.dario 06-20-2017 11:57 AM

That's correct Brenda. The only "field" that'll be different from one command configuration script from another is the "NEW_HOSTNAME" info.

The manual configuration it's very simple:

Right after the NE is logged on:

[CX-OpLab]sysname TestsNamingConvention

And for the interfaces description:

[TestNamingConvention]interface GigabitEthernet6/0/13
[TestNamingConvention-GigabitEthernet6/0/13]description InterfaceNamingConvention

Every NE to manipulate holds the same OS and syntaxis, so the command script can be used to all 5000+ NEs. However the HOSTNAME information must be different for each element.

bgagnon 06-20-2017 01:13 PM

Hi Ruben,

What is the "TestsNamingConvention" pattern you will be using?

What is the "InterfaceNamingConvention" pattern will be using?

Is this something that can be derived from the IP address?

Do you already have a file that contains all 5000 IP addresses?

ruben.dario 06-20-2017 01:24 PM


What is the "TestsNamingConvention" pattern you will be using?
No, this is only an example. The new hostnames will have a format like this: MXTLAM01EDG01 based on our network's parameteres and characteristics.

What is the "InterfaceNamingConvention" pattern will be using?
Same as above.

Is this something that can be derived from the IP address?
No It cant...

Do you already have a file that contains all 5000 IP addresses?
Yep, I do have a file with all 5000 IPs.

bgagnon 06-21-2017 12:07 PM

Hi Ruben,

How do you propose associating the IP addresses with the NEW_HOSTNAME?

I previously asked if you would prompt the user, but you did not reply. Is this info also in a file?

ruben.dario 06-21-2017 02:26 PM

Hello Brenda. It'll be the same username and password for every host...

For your first question, I propose to create an array of host IPs (host.txt). Then use a directory containing individual command configuration script files for each host which names will be set accordingly the IP of the host to be configured. So when the SecureCRT script is executed, the command script files could be executed as well based on the IPs that the SecureCRT is logged on. Did I explain myself crearly (sorry for bad english)?

Let me know your thoughts. Thanks,


bgagnon 06-22-2017 08:30 AM

Hi Ruben,

I thought it made sense to get away from the idea of needing 5000 command files, but that may be the easiest way to associate a new hostname if it can't easily be derived or associated with the current IP address of the device in any other way.

The order of operations will need changed in the example script though. Presently both files (hosts and commands) are opened and all data read into arrays. In your case opening the commands file will depend on the line you are reading from the hosts file.

Another thing to watch out for is that it seems your prompt will change and you will need to detect that in order to "wait for new prompt" before sending that "level of commands".

All times are GMT -6. The time now is 06:31 AM.