1748180 Members
4170 Online
108759 Solutions
New Discussion юеВ

IMAP daemon ping

 
Van Poelvoorde
Occasional Advisor

IMAP daemon ping

Hi,

I'm desperately seeking a tool to verify whether a running imap daemon is indeed up and running and responding.
I know I can try a telnet to the daemon on his listen port (143), but then I'm not able anymore to get out of that Telnet and that's a problem when I want to execute this from a script (the script generates hanging telnet processes under init).
Isn't there any other way ? Is there for example not somewhere a tool like 'imapping' or something like that?

thanks in advance for all your help!
3 REPLIES 3
Robin Wakefield
Honored Contributor

Re: IMAP daemon ping

You could use a here document:

telnet {hostname} 143 < /tmp/imap.test 2>/dev/null
0 logout
!

The check the contents of /tmp/imap.test

Robin.
Vincenzo Restuccia
Honored Contributor

Re: IMAP daemon ping

Edit a file "exit" with vi,in vi ctrl-v (for insert) ctrl-] (for to go in telnet prompt) after edit quit.You have a file with 2 lines ctrl-] and quit.
#telnet {hostname} 143 < exit
Vincent Stedema
Esteemed Contributor

Re: IMAP daemon ping

Hi,

This will only work if you have perl and the IO::Socket module installed. Perl might be installed into another dir on your system.

#!/usr/bin/perl

use strict;
use IO::Socket::INET;

my ( $imap );

$imap=IO::Socket::INET->new( PeerAddr => 'localhost:143');

if(defined($imap) && $imap->connected())
{
shutdown($imap,2);
print "Connection to imap service succeeded.\n";
}
else
{
print "Connection to imap service failed.\n";
}