Global Router Configuration Tool (cisco_config_cmds) |
Top Previous Next |
This program will send any number of configuration commands to a single IOS device or a list of IOS devices. The commands that are sent are defined in a text file (any name), that you create, or specified directly on the command line using the -cmd option. This file MUST NOT include the commands needed to enter and exit configuration mode on the IOS device. The script will automatically enter those commands. The commands are sent in sequential order from top to bottom of the file or the order in which they are defined if using the -cmd options.
Program Name: cisco_config_cmds
The configuration command file (-cf <filename>) should contain a list of configuration commands that will be sent to each router. This is a plain text file that must contain one command per line. Lines that begin with a "#" are considered comments and will not be sent to the router as a command. Th SLEEP command is a special command that will NOT actually be sent to the router. If desired, this is a method to introduce a delay between configuration commands. The syntax is the SLEEP <seconds> (all capitals). Seconds can be a whole integer (e.g. 2) or a real number (e.g. 1.5). The SLEEP command MUST be entered in all CAPITAL letters otherwise it will be interpreted as a command to send to the router. Note, this is not typically needed but may be useful if you would like to watch the script as it is running to visually inspect the output of a particular command.
This script also has the option to run in Test Mode using the -testmode option defined above. With this option, the exact commands that would have been sent to the routers are written to a file (stored in the SCRIPT_HOME directory). The script does not actually login to any devices or send any commands. It is recommended this feature be used when using LOOPING and COUNTER variables (see below)
By default, the configuration commands will not be saved to NVRAM. Use the -wm option to save the configuration changes.
This program also has the option to be run in Safe and SuperSafe mode which should be considered when running scripts in production environments. If entering a configuration command results in an error on the router and the script is running in Safe or SuperSafe mode, the config will not be saved to NVRAM even if the -wm option is applied. If the script is NOT running in Safe or SuperSafe mode, and the -wm option is applied, the config WILL be saved to NVRAM even if there are one or more commands that caused configuration errors.
The following special commands are supported by this script. (Note, output of the commands listed below will NOT be displayed in the contents of individual output files when using the -dir option)
Sample Command 1: The following command will send the configuration commands listed in file snmp_cmds.cmds to the routers listed in the file rtrs.rt. After the configuration commands are entered, the config will be saved to NVRAM because of the -wm option. If there are any errors while sending a particular configuration command, the script will abort all remaining commands to that router and continue on to the next router because of the -safe option (SAFE Mode). The detailed trace-log will be saved to the file snmp_log instead of the default file name of cisco_config_cmds.log (notice this argument was listed first on the command line). The script will not prompt the user for passwords because the passwords are being read in from the logins.txt file (-pw option).
cisco_config_cmds -log snmp_log -pw logins.txt -rf rtrs.rt -cf snmp_cmds.cmds -wm -safe
Sample Command 2: The following script will shutdown interface Gi 0/18 on switch 192.168.0.10. The output log will be saved to an automatically generated unique filename because of the -ulog option. The script will not prompt the user for passwords because the passwords are being read in from the logins.txt file (-pw option). At the first occurrence of an error, the script will abort because of the -safe option. If there are no errors, the config will be saved to NVRAM because of the -wm option.
cisco_config_cmds -ulog -pw logins.txt -ipaddr 192.168.0.10 -cmd "int Gi 0/18" -cmd "shutdown" -wm -safe
|