September 2000
Beginner
408 pages
10h 29m
English
createfolders (shown in Example A-2 ) is a Tcl script that was used in Chapter 9 to create empty Cyrus mailboxes. It takes bsd2cyrus ’s output as input. bsd2cyrus ’s output contains the username, the pathname to a Berkeley-style mail folder, and its mapping into the Cyrus namespace (i.e., the Cyrus mailbox name), but createfolders uses only the Cyrus mailbox name.
Example A-2. createfolders
#!/usr/local/bin/cyradm -file
set inputfile [lindex $argv 0]
eval cyradm connect cyr_conn localhost imap
puts stdout "Connected to IMAP server. Authenticating..."
if [catch {eval cyr_conn authenticate -pwcommand {{
set adminid "cyrus"
set adminpw "xxxxxxxx"
list $adminid $adminpw
}} } result ] {
puts stderr "$result (cleartext)"
return -code error $result
} else {
puts "Authentication successful."
}
## $inputfile is a text file containing username, path to
## Berkeley format folder, and corresponding Cyrus mailbox
if [catch {open $inputfile r} fileId] {
puts stderr "Error: cannot open $inputfile"
} else {
while {[gets $fileId line] >= 0} {
## The Cyrus mailbox is the second field in the input
## line (arrays are indexed starting with 0).
set mailbox [lindex [split $line ":"] 1]
if [catch {cyr_conn createmailbox $mailbox} result] {
puts stderr $result
} else {
puts "Created mailbox $mailbox"
}
}
}