expect脚本实现H3C交换机的配置备份

 

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

相关文章
相关标签/搜索