Tuesday, 26 August 2014

Linux: Remote Shutdown/WoL Window's with 802.1x enabled | Part 3 Automated Macro Scripts

Automated Macro Scripts

This script runs the macros which disables and re-enables dot1x on the switches interfaces.

 #!/usr/bin/expect -f

# Set variables
 set hostname [lindex $argv 0]

# Log results
 log_file -a ~/results.log

# Announce which device we are working on and at what time
 send_user "\n"
 send_user ">>>>>  Working on $hostname @ [exec date] <<<<<\n"
 send_user "\n"

 spawn ssh michael@192.168.1.252

# Allow this script to handle ssh connection issues
 expect {
 timeout { send_user "\nTimeout Exceeded - Check Host\n"; exit 1 }
 eof { send_user "\nSSH Connection To $hostname Failed\n"; exit 1 }
 "*#" {}
 "*assword:" {
 send "$password\n"
 }
 }

 send "macro apply nodot1x\n"
 expect "#"
 send "exit\n"
 expect "#"
 sleep 10
 send "macro apply dot1x\n"
 expect "#"
 exit


 Testing script



So what I've managed to do is get an automated WoL with Remote Shutdown incorporating 802.1x.

Sources;

http://docwiki.cisco.com/wiki/Remote_VTY_Command_Script
http://stackoverflow.com/questions/16385328/expect-scripting-tcl
http://docs.oracle.com/cd/E35328_01/E35336/html/vmcli-script.html
http://paulgporter.net/2012/12/08/30/
http://en.kioskea.net/faq/28828-sending-cisco-commands-sent-via-ssh-telnet

No comments:

Post a Comment