General discussion

Locked

writing a script to ping Windows NT mach

By Vuitanh ·
How do I write a script that run on the Linux/UNIX system that will ping my Windows NT server from time to time to check for Internet connection and Mail server is running. The script must be able to send email to pager.
thanks,

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

writing a script to ping Windows NT mach

by cpfeiffe In reply to writing a script to ping ...

The simple ping would be ping $IP_address. If you want to check that the mail server is running you could use a script similiar to this:
UP=`echo "quit" |telnet $IP 25 |grep SMTP
if [ $UP -eq "" ]; then
some method of notifying you that the mail server is down
(ex. echo $UP |mailx -s "mail
server status" user@domain)
else
exit 0
fi

This script sets the variable UP equal to any line that is returned by you telnetting to the SMTP port on the mail server. If the mail server and the mail service is up you will get back a line that includes SMTP in it. If the service is down for any reason you will get back no line so your variable will equal "" (blank) in which case your script should notify you, otherwise the script will just exit.

To send the email to the pager just use mailx -s "subject" user@domain < contents. user@domain is the pager email address and contents is what you wish to send (i.e "The mail server is down"). You could have also used a method similiar to the example in the script above to get mail out with mailx.

There is one catch. Your linux box must be able to resolve the MX record for your pager domain through DNS.

Collapse -

writing a script to ping Windows NT mach

by Vuitanh In reply to writing a script to ping ...

I didn't check to see if this is valid, but hope this work.

Collapse -

writing a script to ping Windows NT mach

by Vuitanh In reply to writing a script to ping ...

This question was closed by the author

Back to Linux Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums