文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>批量添加samba账户

批量添加samba账户

时间:2006-06-11  来源:CUDev

今天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真是好用~~
相关阅读 更多 +
排行榜 更多 +
巅峰沙盒(国际服)下载安装巅峰沙盒手游国际版下载

巅峰沙盒(国际服)下载安装巅峰沙盒手游国际版下载

飞行射击 下载
易欧app官网软件最新版

易欧app官网软件最新版

金融理财 下载
战狼精英射击手机版

战狼精英射击手机版

飞行射击 下载