SMTP连接错误处理,连接时间长

时间:2015-07-09 16:09:29

标签: bash smtp timeout

如何处理长连接错误/超时?
这是有效的,但不在脚本中......

gtimeout 1 bash -c '3 < /dev/null > /dev/tcp$/{MXHOST}/${MXPORT}

这不会处理漫长的等待/超时:

if (: < /dev/tcp/${MXHOST}/${MXPORT}) 2>/dev/null
# --------------- Creating connection ----------------

if (: < /dev/tcp/${MXHOST}/${MXPORT}) 2>/dev/null
then
    exec 3<> /dev/tcp/${MXHOST}/${MXPORT}
    printf '%-10s %-37s %-37s %-15s\r' "$COUNT" "$TESTEMAIL" "$MXHOST" "Waiting"
    sleep 5
    read -t 5 -u 3 sts line
    connection="$sts $line"
    connsts=${sts:0:3}
    printf '%-10s %-37s %-37s %-15s\r' "$COUNT" "$TESTEMAIL" "$MXHOST" "$connsts"
else
    closests="Failed $?"
    printf '%-10s %-37s %-37s %-15s\n' "$COUNT" "$TESTEMAIL" "$MXHOST" "$closests"
    echo -e "$COUNT \t $TESTEMAIL \t $MXHOST \t $connsts \t $helosts \t $mailsts \t $rcpsts \t $datasts \t $closests" >> resultlog.txt
    continue
fi

0 个答案:

没有答案