Subject: | select problem? |
Date: | Tue, 16 Jan 2007 12:18:37 +0100 |
To: | bug-Net-IMAP-Simple [...] rt.cpan.org, Dani Sanchez <dani [...] fib.upc.edu> |
From: | Dani Sanchez <dani [...] fib.upc.edu> |
Hello,
I have detected that the select command returns a non-value (error?)
when the folder is empty.
This is my test script:
#!/usr/bin/perl
#
use Net::IMAP::Simple;
my ($imaphost, $imapuser, $imappasswd,$imaptimeout,$mbox )=("ZZZZ","YYYY","XXX",60,"nagios");
# Internal Vars
my ($imap,$msgcount,@msglines);
$imap = Net::IMAP::Simple->new($imaphost, timeout=>$imaptimeout);
if (!defined($imap)) {
print("IMAP connect timeout (>$imaptimeout s, host: $imaphost)");
exit -1;
}
if (!$imap->login($imapuser => $imappasswd)) {
print("POP3 login failed (user:$imapuser)");
}
my @folders= $imap->mailboxes();
foreach (@folders) { print("MBOX: $_ \n"); }
$msgcount = $imap->select($mbox);
if (! defined($msgcount) ) {
print ("Error accesing a $mbox -> ##".$imap->errstr ."##\n");
}
# Count messages, that we are looking four:
while ($msgcount > 0) {
@msglines = @{$imap->top($msgcount)};
foreach (@msglines) { print("INBOX: $_ \n"); }
$msgcount--;
}
The output:
MBOX: .mailboxlist
MBOX: Sent
MBOX: mbox
MBOX: Trash
MBOX: Drafts
MBOX: nagios
MBOX: INBOX
Error accesing a nagios -> ##warning unknown return string: * OK [PERMANENTFLAGS (\* \Answered \Flagged \Deleted \Draft \Seen)] Permanent flags
##
The forder exists "nagios" exists and it's empty. When I access to the
empty "nagios" mbox, the select doesn't return any value, but if I put a
message in the folder the script runs ok. I think that the normal
operation would be that returns a "0" value.
The IMAP server is uw-imap IMAP4rev1 2004.357 is and the server is a
SuSE-Linux 9.3 i586 with a 2.6.17-6 kernel
I'ts a bug?
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O O O Daniel Sanchez Dorado
O O O Responsable de Redes LCFIB
O O O Facultad Informatica Barcelona
UPC Tel. 934016933 dani@fib.upc.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~