On Wed, Apr 15, 2009 at 11:47:43PM +0530, Kurian Thayil 
(kurianmtha...@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


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to