[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash Script for Mail sending Check



On Wed, Apr 15, 2009 at 11:47:43PM +0530, Kurian Thayil (kurianmthayil@gmail.com) wrote:


> [...] I need to execute a script
> only after making sure that I am able to send mail using the relay
> server 192.168.0.20 (Postfix enabled). Is it possible for me to write a
> bash script which check this?

Doing it in a general, reliable way with bash alone would be very
difficult, but if it's a local server that always responds fast or not
at all, you could try something like this:

#! /bin/bash
case "$( (sleep 5; echo quit) | telnet  192.168.0.20 25 2>&- )" in
  *'
220 '*) echo Success ;;
  *)    echo Failed ;;
esac

-- 
Tapani Tarvainen


Reply to: