Re: Bash Script for Mail sending Check

2009-04-18 Thread Kurian Thayil
Hi All, Only a working and connection accepting Mail Server gives the status 220. And I will be able to know only using telnet. And generally, if any other application (not a mail server) is running in port 25 (just like SSH in port 25) both `nc` and `nmap` shows open but they won't give status 22

Re: Bash Script for Mail sending Check

2009-04-17 Thread Tapani Tarvainen
On Sat, Apr 18, 2009 at 08:27:43AM +0300, Andrei Popescu (andreimpope...@gmail.com) wrote: > On Sat,18.Apr.09, 08:04:12, Kurian Thayil wrote: > > only whether the port is open or not. But what I need is to check if an > > SMTP server is listening in that port. So I guess the best tool is > > tel

Re: Bash Script for Mail sending Check

2009-04-17 Thread Andrei Popescu
On Sat,18.Apr.09, 08:04:12, Kurian Thayil wrote: > Hi, > > Even I am in the same opinion as Tapani. `nc` or `nmap` actually shows > only whether the port is open or not. But what I need is to check if an > SMTP server is listening in that port. So I guess the best tool is > telnet and to check 220

Re: Bash Script for Mail sending Check

2009-04-17 Thread Kurian Thayil
Hi, Even I am in the same opinion as Tapani. `nc` or `nmap` actually shows only whether the port is open or not. But what I need is to check if an SMTP server is listening in that port. So I guess the best tool is telnet and to check 220 status. I don't think that I'll have to use KILL as there w

Re: Bash Script for Mail sending Check

2009-04-16 Thread Tapani Tarvainen
On Thu, Apr 16, 2009 at 03:38:23PM +0200, Brent Clark (brentgclarkl...@gmail.com) wrote: > what Im really trying to say is that your > code may look a lot neater and easier, as opposed to > > case "$( (sleep 5; echo quit; ps |awk '/telnet/{print "kill "$1}' |sh) | > telnet > 192.168.0.20 25 2

Re: Bash Script for Mail sending Check

2009-04-16 Thread Brent Clark
Alex Samad wrote: how is that different from nmap ? They essentially will both do the job. But im of the opinion that nmap is the wrong tool for the job. Especially considering its for a bash script (You can use swaks too). The beauty about nc is that you can pipe it commands from a file,

Re: Bash Script for Mail sending Check

2009-04-16 Thread Alex Samad
On Thu, Apr 16, 2009 at 01:01:22PM +0200, Brent Clark wrote: > Alex Samad wrote: >> can you use nmap > Hiya > > Why on earth would you wan to use nmap. i thought there might have been a test to see what smtp server is running there ! > > bcl...@zion:~$ dig mx google.com +short > 10 smtp2.google.

Re: Bash Script for Mail sending Check

2009-04-16 Thread Brent Clark
Alex Samad wrote: can you use nmap Hiya Why on earth would you wan to use nmap. bcl...@zion:~$ dig mx google.com +short 10 smtp2.google.com. 10 smtp3.google.com. 10 smtp4.google.com. 10 smtp1.google.com. bcl...@zion:~$ nc -v -z smtp1.google.com 25 smtp1.google.com [209.85.237.25] 25 (smtp) op

Re: Bash Script for Mail sending Check

2009-04-16 Thread Tapani Tarvainen
On Thu, Apr 16, 2009 at 07:56:04PM +1000, Alex Samad (a...@samad.com.au) wrote: > can you use nmap ? It will tell you if the port is open or not, but not whether there is a mail server behind it willing to talk to you. I guess you could first use nmap to check the port and only then try telnettin

Re: Bash Script for Mail sending Check

2009-04-16 Thread Alex Samad
On Thu, Apr 16, 2009 at 09:58:34AM +0300, Tapani Tarvainen wrote: > On Thu, Apr 16, 2009 at 11:28:10AM +0530, Kurian Thayil > (kurianmtha...@gmail.com) wrote: > > > I got your modification working only when telnet gives a prompt, > > Right you are - telnet doesn't react to the escape sequence >

Re: Bash Script for Mail sending Check

2009-04-15 Thread Tapani Tarvainen
On Thu, Apr 16, 2009 at 11:28:10AM +0530, Kurian Thayil (kurianmtha...@gmail.com) wrote: > I got your modification working only when telnet gives a prompt, Right you are - telnet doesn't react to the escape sequence before connecting. Bummer. :-( Oh well, just kill it then: #! /bin/bash case "

Re: Bash Script for Mail sending Check

2009-04-15 Thread Kurian Thayil
Hi Tapani Tarvainen, I got your modification working only when telnet gives a prompt, something like, kuria...@debian:~$ telnet 192.168.0.20 25 Trying 192.168.0.20... Connected to 192.168.0.20. Escape character is '^]'. 220 rhel.virusk.org ESMTP Sendmail 8.13.8/8.13.8; Tue, 14 Apr 2009 22:34:26 +

Re: Bash Script for Mail sending Check

2009-04-15 Thread Tapani Tarvainen
On Thu, Apr 16, 2009 at 09:58:37AM +0530, Kurian Thayil (kurianmtha...@gmail.com) wrote: > I tried the script. Good work. But, one problem though. If the mail > server is firewalled (Netfilter) and if its blocking the client (one > where bash script is run - 192.168.0.10), then `telnet 192.168.0.

Re: Bash Script for Mail sending Check

2009-04-15 Thread Kurian Thayil
Hi Tapani Tarvainen, I tried the script. Good work. But, one problem though. If the mail server is firewalled (Netfilter) and if its blocking the client (one where bash script is run - 192.168.0.10), then `telnet 192.168.0.20 25` will not give any reply but just tries to connect indefinitely. At t

Re: Bash Script for Mail sending Check

2009-04-15 Thread Tapani Tarvainen
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 thi

Re: Bash Script for Mail sending Check

2009-04-15 Thread Eduardo M KALINOWSKI
On Qua, 15 Abr 2009, "Kurian Thayil" wrote: Hi All, I need to write a BASH script which does a set of operations. But this set of operations must be done only after checking if I am able to use a relay server for sending mails. So, consider my client server where bash script would be run as 192.