Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-11-2004, 01:19 PM   #1
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Rep: Reputation: 50
I'm looking for a simply perl script to send mail, when ping down


I'm looking for a simply perl script, when ping down,
then sends mail to administrator.

kind regards
Old 01-11-2004, 02:00 PM   #2
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 67
How about:


$out=`ping -c3 $host | grep -c "bytes from"`;

if($out < 2){
open(MAIL, "|/usr/sbin/sendmail -t");
print MAIL "to:$mail\n";
print MAIL "from:$mail\n";
print MAIL "subject:Cannot ping remote host\n\n";
print MAIL localtime(time());

It will attmpt to ping 3 times if less than 2 replies are received then it sends the admin an e-mail.
Old 01-12-2004, 04:36 AM   #3
Senior Member
Registered: Sep 2003
Distribution: Debian Squeeze / Wheezy
Posts: 1,623

Original Poster
Rep: Reputation: 50
thanks david_ross

works great !

kind regards


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl send mail code pragti Programming 2 03-17-2006 05:48 PM
Send Mail with Perl Cool_Hand_Luke Programming 2 03-14-2005 09:59 AM
Perl form wont send mail calmbomb Linux - Software 4 11-07-2004 10:08 AM
CGI Script runs to send mail, but mail is never sent robertwo Linux - Newbie 2 06-10-2004 09:57 AM
howto send a mail with attachment via perl script ? cccc Programming 24 03-05-2004 07:49 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration