David,
I've been banging my head against the wall trying to get migrate to
work.
Am I doing something wrong?
Here's all the relevant info I can think of:
____SNIP____
$ perl -v
This is perl, v5.6.1 built for sparc-linu
Copyright 1987-2001, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to
the
Internet, point your browser at
http://www.perl.com/, the Perl Home
Page.
pointer@smilingman:~$ uname -a
Linux smilingman 2.4.21-pre7 #2 SMP Tue Apr 15 18:57:28 EDT 2003 sparc64
unknown
____SNIP____
I have a perl script (below) called "change_username.pl" that is
_supposed to login to the cyrus server as 'cyrus' and select 2 mailboxes
(src/dst) and do a migrate between them. This probalbly isn't a problem
with your code, but I figured you might be able to help me out. :)
____SNIP____ change_username.pl
#!/usr/bin/perl
use Mail::IMAPClient;
my $login = "cyrus";
my $pass = "xxxxxxxxx";
my $imaphost = "localhost";
my $folderold = "user/pointer1";
my $foldernew = "user/spamisbad";
eval {
$imapold = Mail::IMAPClient->new(
Server => $imaphost,
User => $login,
Password=> $pass,
Debug => 1,
) or die "Can't connect to $imaphost: $@!";
my $Authenticated = $imapold->Authenticated();
print "imapold authenticated = " . $Authenticated . "\n";
# print join(", ",$imapold->folders),".\n";
};
$imapold->connect or die "Could not connect: $@\n";
if ($@) {
print "Error: $@\n";
}
eval {
$imapold->select($folderold);
};
if ($@) {
print "Error: $@\n";
}
eval {
$imapnew = Mail::IMAPClient->new(
Server => $imaphost,
User => $login,
Password=> $pass,
Debug => 1,
) or die "Can't connect to $imaphost: $@!";
my $Authenticated = $imapnew->Authenticated();
print "imapnew authenticated = " . $Authenticated . "\n";
# print join(", ",$imapnew->folders),".\n";
};
if ($@) {
print "Error: $@\n";
}
eval {
$imapnew->select($foldernew);
};
if ($@) {
print "Error: $@\n";
}
print "The destination mailbox is ";
if ($imapnew->isConnected) {
print "connected.\n";
} else {
print "not connected\n";
}
# $imapold->migrate($imapnew, "ALL", $foldernew )
$imapold->migrate($imapnew, "ALL", "user/spamisbad" )
or die "Could not migrate: $@\n";
# logout and close the conn
$imapold->logout or die "Could not logout: $@\n";
$imapnew->logout or die "Could not logout: $@\n";
____SNIP____
Here's the output from running this script:
____SNIP____
Using Mail::IMAPClient version 2.1.4 and perl version 5.6.1 (5.006001)
Read: * OK smilingman Cyrus IMAP4 v2.1.12-Debian-2.1.12-0woody.11.0
server ready^M
Connect: Received this from readline: 0/OUTPUT/* OK smilingman Cyrus
IMAP4 v2.1.12-Debian-2.1.12-0woody.11.0 server ready^M
Sending: 1 Login "XXXXXXX" "XXXXXXX"^M
Sent 27 bytes
Read: 1 OK User logged in^M
Read: * OK smilingman Cyrus IMAP4 v2.1.12-Debian-2.1.12-0woody.11.0
server ready^M
Connect: Received this from readline: 2/OUTPUT/* OK smilingman Cyrus
IMAP4 v2.1.12-Debian-2.1.12-0woody.11.0 server ready^M
Sending: 2 Login "XXXXXXX" "XXXXXXX"^M
Sent 27 bytes
Read: 2 OK User logged in^M
Sending: 3 SELECT "user/pointer1"^M
Sent 26 bytes
Read: * FLAGS (\Answered \Flagged \Draft \Deleted \Seen)^M
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen \*)] ^M
* 6 EXISTS^M
* 0 RECENT^M
* OK [UNSEEN 1] ^M
* OK [UIDVALIDITY 1051570238] ^M
* OK [UIDNEXT 7] ^M
3 OK [READ-WRITE] Completed^M
Using Mail::IMAPClient version 2.1.4 and perl version 5.6.1 (5.006001)
Read: * OK smilingman Cyrus IMAP4 v2.1.12-Debian-2.1.12-0woody.11.0
server ready^M
Connect: Received this from readline: 0/OUTPUT/* OK smilingman Cyrus
IMAP4 v2.1.12-Debian-2.1.12-0woody.11.0 server ready^M
Sending: 1 Login "XXXXXXX" "XXXXXXX"^M
Sent 27 bytes
Read: 1 OK User logged in^M
Sending: 2 SELECT "user/spamisbad"^M
Sent 27 bytes
Read: * FLAGS (\Answered \Flagged \Draft \Deleted \Seen)^M
* OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen \*)] ^M
* 0 EXISTS^M
* 0 RECENT^M
* OK [UIDVALIDITY 1051289796] ^M
* OK [UIDNEXT 1] ^M
2 OK [READ-WRITE] Completed^M
Sending: 3 isConnected^M
Sent 15 bytes
Read: 3 BAD Unrecognized command^M
Sending: 4 isConnected^M
Sent 15 bytes
Read: 4 BAD Unrecognized command^M
Could not migrate: Invalid or unconnected Mail::IMAPClient object used
as target for migrate.
imapold authenticated = 2
imapnew authenticated = 2
The destination mailbox is not connected
____SNIP____
It shows the second instance of MAIL::IMAPClient logging in and
selecting the mailbox, but then it says it's not connected. Am I doing
something wrong here?
Any help would be greatly appreciated.
Thanks,
Mike
--
Mike Cathey <mike@cathey.us>