This example script copies the Cisco device’s running configuration over its startup configuration.
1. expect.with
2. {
3. if( vendor.equals("9") )
4. {
5. println "copying running config to startup config"
6. sendln "copy running-config startup-config"
7. expect( prompt, {},
8. "Destination filename [startup-config]?", { sendln '' ; CONTINUE } )
9. }
10. else
11. {
12. println "NO VALID METHOD FOR THIS DEVICE"
13. throw new Exception("no valid method for this device")
14. }
15. }
Overview of the copy 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 copy running configuration to startup configuration command.
- Line 8. sets the destination filename to the startup configuration.
- Line 11. to Line 15. return an error message when the device is not a Cisco device.
This script concentrates on Cisco but you could extended it to use with devices from
other vendors.
Comments
0 comments
Please sign in to leave a comment.