- 与shell结合 ``` #! /bin/bash while read ip pass do /usr/bin/expect <<-END &>/dev/null spawn ssh root@$ip expect { "yes/no" { send "yes\r";exp_continue } "passwprd:" { send "$pass\r" } } expect "#" { send "useradd yy1;rm -rf /tmp/*;exit\r" } expect eof END echo "$ip 用户创建完毕" done < ip.txt ``` - 并发执行 ``` tr ":" " " < /ip.txt | while read ip pass do { command }& done ```