oracle脚本自动分发,自动分发脚本
发布日期:2021-06-24 13:15:17 浏览次数:2 分类:技术文章

本文共 1229 字,大约阅读时间需要 4 分钟。

#!/bin/bash

if [ "$1" == "" ];

then

echo -e "\033[1mUsage:\033[0m autofile.sh configfilename url .\n  \033[1m\033[5mNeed configfilename\033[0m\nconfigfilename is a f

ile which contain the ip list you want to patch.\n";

exit;

fi

if [ "$2" == "" ];

then

echo -e "\033[1mUsage:\033[0m autofile.sh configfilename url .\n  \033[1m\033[5mNeed url\033[0m\nthe file is  which  you want to

distribute.\n";

exit;

fi

echo -e "\033[1m\033[5mWARNING: \033[0mHere is the address you want to distribute\033[1m`more $1`\033[0m

if you confirm to do this,please input the server password. otherwise,press ^c to abort the script."

#Get the password

read -p " password:" -s passwd

echo -e "\n"

for host in `more $1 | grep "^[1-9]" `

do

#Extract ip from autoconfig

ip=`echo $host | awk -F: '{print $1}'`

#Extract path from autoconfig

dir=`echo $host | awk -F: '{print $2}'`

#Display the information about host ip  dir

echo -e "\033[1mhost=$host;ip=$ip;dir=$dir;\033[0m"

expect -c"

set timeout 600;

spawn /usr/bin/scp $2  $ip:/$dir

expect {

\"*yes/no*\" {send \"yes\r\"; exp_continue}

\"*password*\" {send \"$passwd\r\";}

}

expect eof"

done

[root@localhost ~]# cat autoconfig

192.168.16.192:/root

Usage:

[root@localhost ~]# ./autofile.sh autoconfig filename

转载地址:https://blog.csdn.net/weixin_33045961/article/details/116539840 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:linux日志文件备份,linux配置文件、日志文件全备份
下一篇:ORACLE客户端jdbc连接测试,Oracle 客户端JDBC连接测试工具

发表评论

最新留言

很好
[***.229.124.182]2024年04月27日 21时13分04秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章