ZsmbPasswd

Just an example of smbpasswd automation.

function die {
    print 1>&2 $*; exit 1
}

function zsmbpasswd {
    local user=$1 oldpass=$2 newpass=$3 line pass result=""
    zmodload zsh/zpty
    zpty smb smbpasswd -U $user
    zpty -t smb || die "Can't execute smbpasswd"

    for pass in $oldpass $newpass $newpass
    do
        zpty -r smb line "*:" || die "Can't read smbpasswd dialog"
        print $line; zpty -w smb $pass
    done
    while zpty -r smb line;
    do
        result+="$line"$'\n'
    done
    zpty -d smb
    print $result
}
 
code/scripts/zsmbpasswd.txt · Last modified: 2010/01/05 09:20 (external edit)