今天samba已经配置好了,但是帐号还没有添加。如果手工添加账户的话,会死掉的,那么多~~
寻找批量添加的方法………………
终于找到了expect
apt-get install expect
主脚本:
#!/bin/sh
#FileName: addsmb_more.sh
while read line
do
#User Name is Lower
name=`echo $line | tr [:upper:] [:lower:]`
#But the original directory is Upper
./expect_smb.sh $name $name
done
expect脚本:
#!/usr/bin/expect -f
#FileName:expect_smb.sh
#Add user to the samba server
# 1---The name of user
# 2---The passwd of user
set username [lindex $argv 0]
set password [lindex $argv 1]
spawn smbpasswd -a $username
expect "*password:"
send "$password\n"
expect "*password:"
send "$password\n"
expect eof
./addsmb_more.sh
问题解决了
expect真是好用~~
阅读(12967) | 评论(0) | 转发(0) |