2. \u7f16\u5199expect\u811a\u672c copyfilebatch.sh<\/strong><\/div>\n\u4e0b\u9762\u7684\u811a\u672c\u5c06\u5411\u5185\u7f51IP\u4e3a 192.168.0.102 \u81f3 192.168.0.112 \u7684\u670d\u52a1\u5668\u5206\u522b\u62f7\u8d1d\u4e00\u4e2arc.local\u6587\u4ef6\uff0c\u62f7\u8d1d\u6210\u529f\u540e,\u6267\u884cchmod\u547d\u4ee4\uff0c\u5206\u522b\u91cd\u542f\u670d\u52a1\u5668<\/p>\n
\r\n#!\/usr\/bin\/expect -f\r\nset password rootpassword\r\n\r\nfor {set i 102} {$i <= 112} {incr i} {\r\n set ip \"192.168.0.$i\"\r\n puts \"$ip\"\r\n\r\n\r\n spawn ssh -o StrictHostKeyChecking=no $ip\r\n set timeout 3\r\n expect \"root@$ip's password:\"\r\n set timeout 3\r\n send \"$password\\r\"\r\n set timeout 3\r\n send \"exit\\r\"\r\n\r\n\r\n spawn scp \/home\/install\/rc.local root@$ip:\/etc\/rc.d\/rc.local\r\n set timeout 3\r\n expect \"root@$ip's password:\"\r\n set timeout 3\r\n send \"$password\\r\"\r\n set timeout 3\r\n send \"exit\\r\"\r\n\r\n spawn ssh root@$ip\r\n\r\n expect {\r\n \"*yes\/no\" { send \"yes\\r\"; exp_continue}\r\n \"*password:\" { send \"$password\\r\" }\r\n }\r\n expect \"#*\"\r\n\r\n #\u8981\u6267\u884c\u7684\u547d\u4ee4\r\n send \"chmod +x \/etc\/rc.d\/rc.local\\r\"\r\n send \"reboot\\r\"\r\n send \"exit\\r\"\r\n expect eof\r\n}\r\n<\/pre>\n\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9<\/p>\n","protected":false},"excerpt":{"rendered":"
\u8fd9\u65f6\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528expect\uff0c\u5411\u76ee\u6807\u670d\u52a1\u5668\u4e0a\u53d1\u9001\u6307\u4ee4\u53bb\u5b9e\u73b0\u6279\u91cf\u64cd\u4f5c\u3002 \u4e0b\u9762\u7684\u4f8b\u5b50\u5c06\u5728centos\u4e0a\u5c06\u4e00\u4e2a\u6587\u4ef6\uff0c […]<\/p>\n","protected":false},"author":1893,"featured_media":194750,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-194749","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/194749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1893"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=194749"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/194749\/revisions"}],"predecessor-version":[{"id":194958,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/194749\/revisions\/194958"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/194750"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=194749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=194749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=194749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}