Of course, contacting SSL ports are a bit more difficult. If you need to probe an IMAPS or POP3S port, telnet just doesn't work. In that case, you can use openssl itself to make the connection and still feed it into an expect script: LD_LIBRARY_PATH /usr/local/ssl/lib export LD_LIBRARY_PATH /usr/local/ssl/bin/openssl s_client -connect localhost:imaps If you know Perl, then maybe you can take it to another level with something like the following: #!/usr/bin/perl -w use strict; use Net::SSLeay; $Net::SSLeay::slowly = 1; ($p) = Net::SSLeay::sslcat("localhost", 993, "."); print $p; The banner should be printed as a result of the above, but you can make the script do anything you want. For non-SSL services, maybe something like the following would work: #!/usr/bin/perl -w use strict; use IO::Socket::INET; my $socket = new IO::Socket::INET("localhost:143"); if (!defined $socket) { print "Unable to connect: $@\n"; exit(1); } print $socket->getline(); print $socket ". logout\n"; $socket->close(); The above also prints the banner. Keep in mind that I spit these out pretty quickly, but I did test them and the scripts work. Hope that helps. Scott --On Monday, October 30, 2006 6:10 PM +0100 Phil Pennock <info-cyrus-spodhuis@xxxxxxxxxxxx> wrote:
On 2006-10-30 at 08:57 -0600, Gary Mills wrote:`telnet' might work, but the script would need to analyze the output and terminate the connection. A timeout would also be helpful. Is `imtest' better for this?Do you have expect installed? Something like the below might help. ----------------------------8< cut here >8------------------------------ # !/usr/local/bin/expect -f spawn -noecho telnet localhost imap expect { timeout {exit 1} -re "Escape character is '(.*)'.\r*\n" {} } expect { timeout {exit 1} eof {exit 2} -re "^. OK .* server ready\r*\n" {} -re "." {exit 2} } send ". LOGOUT\r\n" exit 0 ----------------------------8< cut here >8------------------------------ Regards, -Phil ---- Cyrus Home Page: http://cyrusimap.web.cmu.edu/ Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html
-- +-----------------------------------------------------------------------+ Scott W. Adkins http://www.cns.ohiou.edu/~sadkins/ UNIX Systems Engineer mailto:adkinss@xxxxxxxx ICQ 7626282 Work (740)593-9478 Fax (740)593-1944 +-----------------------------------------------------------------------+ PGP Public Key available at http://www.cns.ohiou.edu/~sadkins/pgp/
Attachment:
pgpuifje2U6Es.pgp
Description: PGP signature
---- Cyrus Home Page: http://cyrusimap.web.cmu.edu/ Cyrus Wiki/FAQ: http://cyrusimap.web.cmu.edu/twiki List Archives/Info: http://asg.web.cmu.edu/cyrus/mailing-list.html