您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 资本运营 > 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}}}}
本文标题:except往集群中复制文件
链接地址:https://www.777doc.com/doc-2871013 .html