标签:shell 批量
#test.sh #!/bin/bash dir=/home/test while read line do host=`echo $line| awk ‘{print $1}‘` passwd=`echo $line | awk ‘{print $2}‘` $dir/expect_ssh.sh $host $passwd & done < $dir/host.txt #expect_ssh.sh #!/usr/bin/env expect set HOST [lindex $argv 0] set PASSWD [lindex $argv 1] spawn ssh root@$HOST expect "(yes/no)?" { send "yes\n" } expect "*password:" { send "$PASSWD\n" } expect "*password:" { send "$PASSWD\n" } expect "*#" { send "useradd -u 0 -g 0 username\n" } #执行相关操作,比如adduser expect eof #host.txt格式,可从数据库中导出 IP passwd
本文出自 “-=湖边竹=-” 博客,请务必保留此出处http://bronte.blog.51cto.com/2418552/1535807
标签:shell 批量
原文地址:http://bronte.blog.51cto.com/2418552/1535807