On 11/27/00 12:19 PM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:

> Is there an easy way to invoke the perl cyradm from a script to
> create mailboxes for new users?  I'd like to incorporate this into
> our account creation scripts to do a few simple things such as
> create the mailbox and set the quota.  Would it be better to use
> the underlying perl library instead?  I'd like to put the administrator's
> username and password, and the server name into a file, and have the
> rest of the information fed from the script.

I've gotten around this (with the older non-perl cyradm) by creating an
expect script to add my users automatically and set the mailbox quota. I
don't expect this would be much different for the Perl version.

All I do is give the script the username as an argument and it does the
rest.

Here it is:

#!/usr/bin/expect

set force_conservative 1  ;# set to 1 to force conservative mode even if
              ;# script wasn't run conservatively originally
if {$force_conservative} {
    set send_slow {1 .1}
    proc send {ignore arg} {
        sleep .1
        exp_send -s -- $arg
    }
}

set username [lrange $argv 0 0]

set timeout 2

# Start the program.
spawn /usr/local/cyrus-imapd-1.6.24/bin/cyradm -user mailadmin localhost
match_max 100000

# Look for the Password: line and send the password.
expect -exact "Password: "
send -- "password\r"
expect -exact "\r
localhost.localdomain> "

# Create the mailbox user.$username.
send -- "cm user.$username\r"
expect -exact "cm user.$username\r
localhost.localdomain> "

# Set the quota to 200MB. That should be enough.
send -- "sq user.$username 200000\r"
expect -exact "sq user.$username 200000\r
localhost.localdomain> "

#
send -- "quit\r"
expect eof



You may already have expect on your system, if you run the utility
"autoexpect" it will watch what you're doing and create a script for you
(that you can modify however you'd like after).
-- 
Darron
[EMAIL PROTECTED]

Reply via email to