标签:
#!/usr/bin/expect
set user [lindex $argv 0]
set pass [lindex $argv 1]
spawn useradd -s /bin/sh -d /home/$user $user
expect "*#"
spawn passwd $user
expect "*password:"
send "$pass\r"
expect "*password:"
send "$pass\r"
spawn smbpasswd -a $user
expect "*password:"
send "$pass\r"
expect "*password:"
send "$pass\r"
interact
注释:
spawn: 后面加上需要执行的shell 命令
expect: 只有spawn 执行的命令结果才会被expect 捕捉到,因为spawn 会启
标签:
原文地址:http://www.cnblogs.com/zclzhao/p/5462391.html