#!/bin/bash
#
# Declare host variable as the input variable
WJ_TARGET=<ip device>
WJ_USER=<user>
WJ_PASS=<password>
WJ_INTR=Fa0/48
WJ_EXT="`echo $WJ_INTR|tr 'A-Z' 'a-z'|tr '/' '-'`"
# Start the expect script
(expect -c "
set timeout 10
# Start the session with the input variable and the rest of the hostname
spawn ssh $WJ_USER@$WJ_TARGET
expect \"*assword:\"
send \"$WJ_PASS\r\"
expect \"*#\"
#
# Allow us to interact with the switch ourselves
#
send \"show interface $WJ_INTR\r\"
expect \"*--More--*\"
send \" \r\"
send \"config terminal\r\"
expect \"*#\"
send \"interface $WJ_INTR\r\"
expect \"*#\"
send \"shutdown\r\"
expect \"*#\"
send \"do show interface $WJ_INTR\r\"
expect \"*#\"
send \"no shutdown\r\"
expect \"*#\"
send \"do show interface $WJ_INTR\r\"
expect \"*#\"
expect \"*#\"
send \"\^Z\"
expect \"*#\"
send \"exit\r\"
#
# stop the expect script once the telnet session is closed
exit
")
No comments:
Post a Comment