1,先設置交換機設置不分屏ssh
user-interface vty 0 4ide
screen-length 0spa
2,編輯expect腳本crontab
cat discu.expit
#!/usr/bin/expectclass
set timeout 10配置
spawn ssh -l admin 192.168.0.1im
expect "password"腳本
send "123456\r"word
sleep 1
send "dis cu \r"
send "q \r"
expect eof
exit
3,加入crontab作按期配置保存:
30 23 * * 5 /root/tasks/expect.sh > /root/tasks/discu.txt 2>&1