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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



new2perl2016
Novice

Mar 9, 2016, 8:17 AM

Post #1 of 2 (2827 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,
state:{lastUpdatedDateTime:1427129443000,id:billybob,key:
37581,oldDbKey:41984,type:TakerUser,lastUpdatedBy:billybob,
partyId:ARAGORN,permissions:{perms:[,SequesteredTrading],
tkrPerms:{perms:[AlternateUpdateXXXFundName,
AlternateUpdateXXXscriptions,AlternateIcebergOrder],
rfqTradeWarnLimit:0,rfqTradeAbsoluteLimit:0,
espTradeAbsoluteLimit:0}}}} sendServer#'


Code
 
#use strict;
my $mail_d = 'apples@yahoo.com';

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\@yahoo.com'; set envelope_from=yes\" -s 'TEST Alert! SOMETHING CHANGED' -- $mail_dest";
#print ML "$line";
#close ML;
next;
}

}

close FF;

As always your feedback is greatly appreciated.


FishMonger
Veteran / Moderator

Mar 9, 2016, 9:32 AM

Post #2 of 2 (2822 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