Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1691631
  • 博文数量: 362
  • 博客积分: 10587
  • 博客等级: 上将
  • 技术积分: 4098
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-10 18:15
文章分类

全部博文(362)

文章存档

2014年(1)

2013年(58)

2011年(115)

2010年(112)

2009年(76)

分类: LINUX

2013-03-21 20:19:10


  1. #!/usr/bin/expect

  2. set allhosts [open hosts.txt r]
  3. foreach all [read $allhosts] {
  4.     puts "$all"
  5.     set passwd "123456"
  6.     set newpasswd "12345678"
  7.     spawn /usr/bin/ssh root@$all
  8.     
  9.     expect {
  10.     "yes/no" { send "yes\r"; exp_continue}
  11.     "Password: " { send "$passwd\r" }
  12.     }

  13.     expect "#"
  14.     send "export LANG=\"en_US\"\r"

  15.     expect "#"
  16.     send "passwd\r"

  17.     expect "password:"
  18.     send "$newpasswd\r"

  19.     expect "password:"
  20.     send "$newpasswd\r"
  21. }
  22. expect eof
  23. close $allhosts

  24. exit

阅读(883) | 评论(0) | 转发(0) |
0

上一篇:perl ping代码

下一篇:bash shell多行注释

给主人留下些什么吧!~~