shell分发文件脚本
配置文件scp.conf
ssh_hosts=("IP") #需要分发机器的所有IP
ssh_ports=("22")
ssh_users=("root")
ssh_passwords=("密码")
except免秘钥脚本
#!/usr/bin/expect
#host
set scphost "[lindex $argv 0]"
#ssh端口
set port "[lindex $argv 1]"
#ssh用户名
set scpuser "[lindex $argv 2]"
#ssh密码
set scppw "[lindex $argv 3]"
#要上传的文件名或者目录
set file "[lindex $argv 4]"
#要上传到远程机器的文件名或者目录
set target "[lindex $argv 5]"
`scp -r -P $port $file $scpuser@$scphost:$target`
scp分发脚本
#用来通过scp批量上传文件或者目录到目标机器的指定目录
#配置文件格式:
#ssh_hosts=("1.1.1.1" "2.2.2.2")
#ssh_ports=("22" "22")
#ssh_users=("root" "root")
#ssh_passwords=("12" "23")
#执行:sh multi_scp.sh conf_file_path file target #upload shell script file path
scp_upload=scp_upload.sh
#then upload file path
scp_file=$1
#remote host'target file or dir path
scp_target=$2 conf_file=scp.conf
if [ $# == 3 ]
then
conf_file=$3
fi #判断conf_file配置文件是存在
if [ ! -e "$conf_file" ]
then
echo "$conf_file is not exists";
exit;
fi
#判断scp_file是文件或者目录
if [ ! -e "$scp_file" ] && [ ! -d "$scp_file" ]
then
echo ""
#echo "$scp_file is not exists";
#exit;
fi
#read configure file
source $conf_file
for((i=0;i<${#ssh_hosts[@]};i++))
do
#remote ssh host
ssh_host=${ssh_hosts[$i]}; #remote ssh port
ssh_port=${ssh_ports[0]}; #remote ssh user
ssh_user=${ssh_users[0]}; #remote ssh password
ssh_password=${ssh_passwords[0]}; while read line
do
target_path=`echo $line | awk '{print $1}'` #echo "["`date +"%F %T"`"] (scp -r $scp_file $ssh_user@$ssh_host:$ssh_port:$target_path) start"
#`scp -r -P $port $file $scpuser@$scphost:$target`
#scp file or dir
echo "to "$ssh_host":"$target_path
scp -r -P $ssh_port $scp_file $ssh_use@$ssh_host:$target_path #echo "["`date +"%F %T"`"] (scp -r $scp_file $ssh_user@$ssh_host:$ssh_port:$target_path) end"
#echo ""
done < $scp_target
done
记录下,怕以后找不到了
shell分发文件脚本的更多相关文章
- shell 处理文件脚本
[root@centos-6 ~]# cat info_file.txt lys:28:shanxi zhy:28:shanxi [root@centos-6 ~]# cat info_file2.t ...
- hadoop_批量命令脚本&同步文件脚本
1.xcall.sh 批量命令脚本,例:xcall.sh jps ,查看hadoop101~ hadoop104的jps进程 注意:在执行命令的时候,若是提示没有这个命令,但是在本机又可以执行,记得在 ...
- Shell 分发脚本
目录 Shell分发脚本 原理 rsync命令分析 特点 基本语法 实现 需求 环境变量 脚本实现 知识点 获得当前路径的目录dirname 获得当前路径的文件名basename shell远程执行命 ...
- Shell执行将脚本里的变量打印到指定日志文件
首先需要定位获取任务的运行日志或者报错信息,才能定位问题. 通过shell调用有些脚本的话,日志信息会打印在shell里.不过也有用户在shell里调用正常,但是到crontab调用的时候就出错并且没 ...
- Hadoop概念学习系列之Java调用Shell命令和脚本,致力于hadoop/spark集群(三十六)
前言 说明的是,本博文,是在以下的博文基础上,立足于它们,致力于我的大数据领域! http://kongcodecenter.iteye.com/blog/1231177 http://blog.cs ...
- Bash Shell启动配置脚本的顺序
1.Bash检查环境变量文件的方式,取决于系统运行Shell的方式,通常系统运行Shell有3种方式: )通过系统用户登陆后默认运行的Shell )非登陆交互式运行Shell )执行脚本运行非交互式S ...
- Shell编程-01-Shell脚本初步入门
目录 什么是Shell 什么是Shell脚本 Shell脚本语言的种类 常用操作系统默认Shell Shell 脚本的建立和执行 脚本规范 什么是Shell 简单来说Shell其实就是一个命令 ...
- Shell编程(脚本)的经常使用命令和语句
一些经常使用的Shell编程(脚本)命令和语句,能够满足一般需求. 接收到的命令參数: 參数个数: $# 參数值: 命令本身:$0 第一个參数:$1 第二个參数:$2 -- 退出命令: exit ec ...
- Shell,Bash,等脚本学习(有区别)
二元比较操作符,比较变量或者比较数字.注意数字与字符串的区别. 整数比较 -eq 等于,如:if [ "$a" -eq "$b" ] -n ...
随机推荐
- 0301001_Lesson1&2
Lesson 1 Excuse me! 对不起! Listen to the tape then answer this question.Whose handbag is it?听录音,然后回答问题 ...
- Java面试题集合
1.Java的HashMap是如何工作的? HashMap是一个针对数据结构的键值,每个键都会有相应的值,关键是识别这样的值. HashMap 基于 hashing 原理,我们通过 put ()和 g ...
- selenium 的安装使用
直接pip安装 pip install selenium 默认是火狐浏览器,需要安装下面网址的软件,解压后加入到环境变量中就可以了 https://github.com/mozilla/geckodr ...
- Android之 GPS学习笔记
========================================GPS:全球定位系统 GPS由三部分组成:GPS卫星组成的空间部分,若干地面组成的控制站,用户手中的接收机.Androi ...
- 基于eth快速发行自己的数字货币
我们总在寻觅,也不断迷失. 像一颗飘摇的韭菜,彷徨而又无奈,无奈又彷徨. 如果你问我未来,我不知去向何方 我只知道生长,恣意野蛮. 我们不断在追寻一款爆款的项目,一个百倍币千倍币,却没有想到,实际上做 ...
- URAL 1936 Roshambo(求期望)
Description Bootstrap: Wondering how it's played? Will: It's a game of deception. But your bet inclu ...
- input设置为readonly后js设置intput的值后台仍然可以接收到
今天发现一个奇怪现象,一个input属性readonly的值被设置为readonly,然后有前台js给input设置了新值. 虽然前台看不到效果,但是提交到后台后,仍然可以接收到新值,感觉很奇怪. 我 ...
- lintcode-63-搜索旋转排序数组 II
63-搜索旋转排序数组 II 跟进"搜索旋转排序数组",假如有重复元素又将如何? 是否会影响运行时间复杂度? 如何影响? 为何会影响? 写出一个函数判断给定的目标值是否出现在数组中 ...
- Delphi xe7组件和控件的安装方法
暂时我所遇到的所有控件安装方法大体与下面两种相同. 若有不同大家提出来,一起想办法解决. .dproj格式的组件安装方法: raise组件 安装详细步骤如下: 一.设置搜索路径1. 将本包中的文件连同 ...
- android中常见的命名及其特点详解
Paseal命名法 Paseal命名法特点:String MyName-DelphiInt MyAge每个单词首字母大写 Camel命名法 Camel(驼峰的意思)命名法特点:String myNam ...