CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
Why is multi line output in $var being sending out multiple emails for each line



Mar 9, 2016, 8:17 AM

Post #1 of 2 (3973 views)
Why is multi line output in $var being sending out multiple emails for each line Can't Post

Hi Gents,

Can you advise why this behavior is happening. I have a multi line file which I stripped out and captured to a variable $line. If I print to the screen the standard out seems to be fine. But if I run the script through email it sends out 2 separate emails, 1 for each line.

Mar 9 15:01:30 Updating servercert for user=(billybob), updated by billybob ,partyIdxx: Toasties[vlogs@hostname myscripts]$

any ideas? been looking all over and can't seem to find a solution.

text file --

'Feb 19 15:22:21 206021 152221.684878 7219 Session-60 INFO:
Updating servercert for user=(billybob) imadesomechanges,
updated by billybob
Feb 19 15:22:21 206021 152221.694424 7220 server.framework.
scsf.client Session-60 INFO: MessageFromClient{msgId:UPDATE,
espTradeAbsoluteLimit:0}}}} sendServer#'

#use strict;
my $mail_d = '';

my $logpath = "cat /test/integration123/logs-std/`date +%H`";

open FF, "$logpath |";

while (<FF>) {
#print "LINE = $_";

if ( /Updating servercert/ .. /sendServer/ ) {

#print "$_";
my $line = $_;
# s/\n//g;
#$line =~ s/\n//g;
#print "$line";
chomp ($line);
$line =~ s/systems.*INFO://;
$line =~ s/\) .*updated/), updated/;
$line =~ s/^.*party:/ ,party: /;

$line =~ s/,perms.*$//;
print "$line";

#open ML, "| mutt -e\"set realname='Customer Support Group'; set use_from=yes; set from='supportgroup\'; set envelope_from=yes\" -s 'TEST Alert! SOMETHING CHANGED' -- $mail_dest";
#print ML "$line";
#close ML;


close FF;

As always your feedback is greatly appreciated.

Veteran / Moderator

Mar 9, 2016, 9:32 AM

Post #2 of 2 (3968 views)
Re: [new2perl2016] Why is multi line output in $var being sending out multiple emails for each line [In reply to] Can't Post

That script has a number of problems, but the one you're asking about is due to having the sending of the email inside the loop.

On another note, please post beginner questions like this in the beginner section.

(This post was edited by FishMonger on Mar 9, 2016, 9:33 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives