Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6910290
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15948
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类:

2012-12-26 19:58:51

记录一下
自动批量修改cisco交换机密码

点击(此处)折叠或打开

  1. #!/usr/bin/expect -f

  2. #file name: chswpw.exp
  3. #Usages: batch change switch manager password
  4. #Version: v1.1
  5. #By Create Edward.zhou
  6. #Date: 2012-12-23

  7. set timeout -1

  8. set oldpasswd [lindex $argv 0]
  9. set oldenapwd [lindex $argv 1]
  10. set swhost [lindex $argv 2]
  11. set newpasswd [lindex $argv 3]
  12. set newenapwd [lindex $argv 4]
  13. set newconpwd [lindex $argv 5]

  14. if { $argc <=3 } {
  15. puts "Usage $argv0 passwd enablepasswd switchhost tftpserver\r"
  16. puts "Use Method: ./chswpw.exp oldpasswd oldenapwd swhost newpasswd newenapwd newconpw\r"
  17. exit 1
  18. }

  19. spawn telnet $swhost
  20. expect "Password:"
  21. send "$oldpasswd\r"
  22. expect "*>"
  23. send "enable\r"
  24. expect "Password:"
  25. send "$oldenapwd\r"
  26. expect "*#"
  27. send "conf t\r"
  28. expect "*fig)#"
  29. send "enable secret $newenapwd\r"
  30. expect "*fig)#"
  31. send "line vty 0 4\r"
  32. expect "*line)#"
  33. send "password $newpasswd\r"
  34. send "exit\r"
  35. expect "*fig)#"
  36. send "line con 0\r"
  37. expect "*line)#"
  38. send "password $newconpwd\r"
  39. send "exit\r"
  40. send "end\r"
  41. expect "*fig)#"
  42. send "wr\r"
  43. send "end\r"
  44. send "exit\r"
  45. send "\r"
  46. #interact


阅读(484) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~