This example log out script only applies to Cisco devices. It sends 4 exit commands. Depending upon the login depth of the device, not all of these exit commands are required - those that are not necessary are simply ignored.
The log out script is intended as the last step in tasks that require logging into devices.
1. expect.with
2. {
3. if( vendor.equals("9") )
4. {
5. sendln( "exit" )
6. sendln( "exit" )
7. sendln( "exit" )
8. sendln( "exit" )
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 log out script structure:
- Line 3. finds the seventh character of the sysOID to identify the device vendor.
- Line 4. to Line 9. send exit commands to the device.
- Line 10. to Line 14. return an error message when the device is not a Cisco device.
Comments
0 comments
Please sign in to leave a comment.