#!/bin/bash

if [ $# -le  ]; then
echo -e "usage : \n\t$0 hostList src_file dst_path"
echo -e "example: \n\t$0 hostList file.txt /home/work/opdir"
exit
fi # concurrent number by default.
CON_NUM=
host_list=$
shift src=''
while [ $# -gt ]; do
src="$src $1"
shift
done
dst=$ echo "src: $src"
echo "det: $dst" if [ ! -f $host_list ]; then
echo "$host_list is not exist!"
exit
fi function your_cmd() {
host=$
#echo -e "---- cmd() start to : $host --"
CMD="scp -r ${src} ${host}:${dst} 2>/dev/null"
eval ${CMD}
ret=$?
if [ $ret -ne ];then
echo -e "\t$host: cmd return retry $ret"
fi
} function concurrent()
{
# ff_file which is opened by fd will be really removed after script stopped
mkfifo ./fifo.$$ && exec <> ./fifo.$$ && rm -f ./fifo.$$ # initial fifo: write $con_num line to $ff_file
for ((i=; i<=$CON_NUM; i++)); do
echo "init:$i" >& # init fifo
done for host in $(cat $host_list | grep -v "^#"); do
read -u # read from fifo to REPLY
{
#echo -e "\n-- current loop for: \"$host\" [ fifo id: \"$REPLY\" ]"
your_cmd "$host"
echo -e "---- done: $host ----\n"
echo "real:$host" >& # write to $fifo
} & # & to backgroud each process in {}
done
wait # wait all con-current cmd in { } been running over
} concurrent

最新文章

  1. emmet的使用
  2. 整理iOS9适配中出现的坑(图文)
  3. 混合App 框架选型
  4. Core Animation一些Demo总结 (动态切换图片、大转盘、图片折叠、进度条等动画效果)
  5. netstat 查看TCP状态值
  6. 用ubuntu下载电影:磁力链接,torrent,迅雷链接
  7. OpenGL的几何变换[转]
  8. [Codeforces Round#286] A.Mr. Kitayuta, the Treasure Hunter 【Normal DP..】
  9. HDOJ(HDU) 1678 Shopaholic
  10. WAV文件格式分析
  11. SQL SERVER FOR 多列字符串连接 XML PATH 及 STUFF
  12. linux下vsftpd的安装及配置使用详细步骤
  13. Python基础:编码规范(4)
  14. node.js 模块的分类
  15. SpringMVC(三十) 实例:SpringMVC_RESTRUL_CRUD_显示所有员工信息
  16. EasyWeChat使用(laravel框架下)
  17. (二维数组 亿进制 或 滚动数组) Hat&#39;s Fibonacci hdu1250
  18. Java基础--对象的克隆
  19. Linux的SSH免密登录认证过程研究
  20. mysql读写分离[高可用]

热门文章

  1. MyBatis开发学习记录
  2. (五)solr7.1.0之solrJ的使用
  3. Drools文档(八) 规则语言参考
  4. 多服务器操作利器 - Polysh
  5. 拓扑排序&amp;关键路径
  6. 01.redis初识
  7. 《Linux命令行与shell脚本编程大全》第二十五章 创建与数据库、web及电子邮件相关的脚本
  8. P1378 油滴扩展
  9. 51Nod--1012最小公倍数
  10. CCF-201403-1-相反数