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

Reply via email to