This script compares the Cisco device’s running and startup configurations. It is not included with the example scripts.
1. expect.with
2. {
3. if( vendor.equals("9") )
4. {
5. println "Compare Running and Startup Config"
6. sendln "show archive config differences"
7. expect( prompt, {},"--More--", { send " "; CONTINUE})
8. }
9. else
10. {
11. println "NO VALID METHOD FOR THIS DEVICE"
12. throw new Exception("no valid method for this device")
13. }
14. }
Overview of the compare running configuration to the startup configuration script structure:
- Line 3. finds the seventh character of the sysOID to identify the device vendor.
- Line 5. prints the purpose of the script. This is available through the job history details.
- Line 6. sends the command to show the differences between the running configuration and startup configurations.
- Line 7. tests the response to the command. This has two purposes:
- Building the running configuration takes time and without this line the script would complete before it had received a response from the device. expect( prompt, {} causes the script to wait until the prompt returns on the terminal and therefore it can receive the result of the configuration comparison.
- The configuration comparison may return more than one page of data. The terminal command line would display --More-- and wait for you to press the space bar to view the next page. "--More--", { send " "; CONTINUE} checks if there is another page to display and if so sends a space.
When you press the space bar in response to --More-- the device deletes --More-- from its cache before presenting the next page. When accessed from the command line this is invisible to the user, when accessed through Entuity Configuration Management it is captured as two blocks of question marks, i.e. ????????? ?????????.
- Line 9. to Line 13. return an error message when the device is not a Cisco device.
Comments
0 comments
Please sign in to leave a comment.