今天好生气,是她让我不开心的,直接关了她的NOTEBOOK在交换机上的端口,
但这样也显得我太笨啦!写一个SHELL,不如让她一分钟掉一次线来得痛快。
以下是EXPECT程序:
#!/bin/sh
disport() //关闭端口程序头
{
while read line
do
expect <
set timeout 1
spawn telnet $line
expect "login:"
send "admin\n"
expect "password:"
send "vangeldoro\n" //交换机passwd(这里设成vangeldoro)
expect "*>" //进入交换机普通模式
send "en\n"
expect "*password:"
send "vangeldoro\n"
expect "*#" //进入交换机管理模式
send "config port 22 dis\n" //关闭交换机上22端口
expect off
end
done < /home/vangeldoro/Script/sip.dat //源IP地址,放在sip.dat中
}
enableport() //使能端口程序头,同上
{
while read line
do
expect < spawn telnet $line
expect "login:"
send "admin\n"
expect "password:"
send "vangeldoro\n"
expect "*>"
send "en\n"
expect "password:"
send "vangeldoro\n"
expect "*#"
send "con por 22 en\n"
expect off
end
done< /home/vangeldoro/Script/sip.dat
}
while true
do
disport
enableport
sleep 60
done
其中/home/vangeldoro/Script/sip.dat 为存放IP地址的文件
里面是交换机的IP address
如:我的是192.168.200.249
(注,我这里用的交换机是HammerOS Version 1.2(Release 1.23) on uHammer3550-24.
在其它交换机上也是大同小异)
阅读(1426) | 评论(0) | 转发(0) |