except往集群中复制文件

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#!/usr/bin/expect-fprocenter_ssh_password{ipuserpasswd}{expect{Areyousureyouwanttocontinueconnecting(yes/no){sendyes\rexp_continue}$user@$ip'spassword:{send$passwd\r}}}spawnecho所拷贝的文件夹需要是全路径,拷贝过去的路径与本机路径一致,注意末尾不能加/,应该如./scpFolderToCluster/home/inspur/MyBin/test#如果没有参数,就直接返回if{[llength$argv]1}{spawnecho没有参数,需要输入文件夹的路径interactreturn}#注意必须是ip地址sethosts172.16.1.31172.16.1.32172.16.1.33172.16.1.5172.16.1.6172.16.1.7172.16.1.8172.16.1.9172.16.1.10172.16.1.14172.16.1.15172.16.1.16172.16.1.17172.16.1.18setuserrootsetpasswdxxxxxxxxxxxxxxxxxxsetfolder[lindex$argv0]setlocal[execsh-c{ifconfigeth0|grepMask|cut-d:-f2|awk'{print$1}'}]spawnecho$localsetparpath[split$folder/]setparpathlen[llength$parpath]incrparpathlen-2setparpath[lrange$parpath0$parpathlen]setparpath[join$parpath/]spawnecho$parpathforeachhost$hosts{if{$host!=$local}{#测试是否能联通spawnping-c1$hostexpect{1packetstransmitted,1received,0%packetloss,time{spawnsshroot@$hostmkdir-p$parpathenter_ssh_password$host$user$passwdinteractif{[fileisdirectory$folder]}{spawnscp-r$folderroot@$host:$parpath}else{spawnscp$folderroot@$host:$parpath}enter_ssh_password$host$user$passwdinteract}}}}

1 / 2
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功