What i want to do is next to the URLs i want to specify the Email addresses to which the failures are to be mailed. How can i read them from the text file itself.
Also I want to create a log file after a certain no. of failures. How can I do that ?
Mailing is not a problem as i can use Email::Send::Gmail for it. I am posting my script below. Kindly Help. Thanx in advance.Testfile#!/usr/bin/perl use warnings; use LWP::Simple; use Email::Send; use Email::Send::Gmail; use Email::MIME::Creator; use Net::Ping::External qw(ping); use Tie::File; my $testfolder = "/Users/Appy/Desktop/"; my $to = "test1\@gmail.com"; my $from = "test2\@gmail.com"; my $subject = "Uris not responding."; my $count = 1; tie @file, 'Tie::File', $testfolder . "testfile.txt" or die; foreach $URL (@file) { my $string1 = $URL; if ( $string1 =~ m/ # Match ping\s # 'ping ' /ix # i = Ignore case # x = allow the regexp to go over multiple line +s ) { my $URI = substr $URL, 8; print "$URI\n"; sub myping { my $alive = ping(host => "$URI"); if ($alive) { print "$URI is active.\n"; } else { my $c = substr $URL, 5, 2; $count = $count + 1; if ($count <=round($c/2)) { &myping; } if ($count=$c) { ##create a log file } } }
ping 07 abc.in a@b.com,c@d.com
ping 05 google.co.in e@f.com,g@h.coms include the respective email addresses to which notification is to be sent. and the numbers specify the no. of failures after which the email has to be sent
In reply to Reading Email List from a text file by Appy16
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |