pop3check

##pop3check.sh

#!/bin/bash

/etc/zabbix/externalscripts/pop3check.exp $1 $2 | grep 'OK Logging out' | wc -l

##pop3check.exp

#!/usr/bin/expect
## Param Check
if {$argc != 2} {
send_error "Parameter Error ... \n"
send_error "Usage: pop3check.exp {POP3_HOST USER_NAME}\n"
exit
}

## Set Constants String
set POP3_HOST [lindex $argv 0]
set USER_NAME [lindex $argv 1]

set TELNET "/usr/bin/telnet"

set timeout 5

spawn $TELNET $POP3_HOST 110;

expect {
default {exit 2}
"OK Dovecot ready."
}

send "USER $USER_NAME\n"
expect -re "OK"
send "quit\n"
interact