scripted delete mailbox for cyradm

Craig White craigwhite at azapple.com
Thu Feb 10 13:31:46 EST 2005


On Thu, 2005-02-10 at 11:02 -0600, Aleksandar Milivojevic wrote:
> Craig White wrote:
> > Trying to script deleting a user's mailbox from system...
> > 
> > /bin/su - cyrus -c '/usr/lib/cyrus-imapd/cyradm localhost \ 
> > --userrc=/var/lib/imap/.systemrc dm user.public'
> 
> Try something like this instead:
> 
> #! /usr/bin/perl -w
> 
> use Cyrus::IMAP::Admin;
> 
> $imap = Cyrus::IMAP::Admin->new("servername")
>     or die "Failed to connect";
> $imap->authenticate("-user" => "username",
>                      "-password" => "password",
>                      "-mechanism" => "LOGIN")
>     or die "Failed to authenticate";
> $imap->delete("user.mailbox")
>     or die "Failed to delete mailbox";
> 
> See man pages for Cyrus::IMAP::Admin and Cyrus::IMAP for more details.
----
OK - I think I can deal with this but...

#cyradm localhost
IMAP Password:
<localhost.localdomain> lm user.public
user.public (\HasNoChildren)

and
# ./ldap_useradmin.deluser
Failed to delete mailbox at ./ldap_useradmin.deluser line 11.

#cat ldap_useradmin.deluser
#! /usr/bin/perl -w

use Cyrus::IMAP::Admin;

$imap = Cyrus::IMAP::Admin->new("localhost")
    or die "Failed to connect";
$imap->authenticate("-user" => "cyrus",
                     "-password" => "MY_PASS",
                     "-mechanism" => "LOGIN")
    or die "Failed to authenticate";
$imap->delete("user.public")
    or die "Failed to delete mailbox";

means we died and didn't delete the mailbox.

as you can see from cyradm, the mailbox is indeed there and called
'user.public' 

so this defies my ability to discern what is going on

and lastly, since this is perl and I'm a lost duck, is there a way to
direct standard and error out on this to a file? I love to have a means
to keep track of what happened when I call from another process and
don't have a terminal to work with.

Thanks

Craig

---
Cyrus Home Page: http://asg.web.cmu.edu/cyrus
Cyrus Wiki/FAQ: http://cyruswiki.andrew.cmu.edu
List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html




More information about the Info-cyrus mailing list