网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  expect嵌套shell循环

expect嵌套shell循环

分类: IT文章 • 2022-08-27 23:54:13
#!/bin/bash

Detailtxt="test.txt"
while read line

do

   dest=`echo $line|awk '{print $1}'`
   ip=`echo $line|awk '{print $2}'`
   /usr/bin/expect <<-EOF
   spawn scp /etc/hosts root@ip:$dest
   expect { 
"yes/no" {send "yes
";exp_continue}
"password:" { send "密码
" }
}

   expect "*#"
EOF


done < $Detailtxt

其中test.txt格式如下

/tmp ip地址

相关推荐

  • shell循环
  • 为什么java代码中要避免多层深度for循环嵌套
  • shell中的for循环用法详解
  • linux基础学习-19.6-Shell脚本-循环
  • shell 时间循环
  • sql语句中嵌套2层循环
  • while、dowhile、switchcase 循环嵌套、穷举、迭代
  • thinphp中volist嵌套循环时变量$i 被污染问题,key="k"
  • shell脚本编程基础之while、for、until循环 while及until循环结构 退出循环的控制关键词 while的特殊用法 示例 for循环的C语言风格形式
  • shell脚本编程基础之for循环 循环结构 生成列表及示例 组合条件测试 德·摩根定律
  • 【Atcoder】AGC 020 B
  • 【BZOJ】2154: Crash的数字表格 莫比乌斯反演
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号