Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > newbie: unusual email output

Reply
Thread Tools

newbie: unusual email output

 
 
Duke of Hazard
Guest
Posts: n/a
 
      01-21-2004
I have this code:
-----------------

print MAIL "Comments if any:\n";
print MAIL "================\n\n";
print MAIL "$x_comments";
print MAIL "\n\n";

close (MAIL);

Which produces this unexpected output when x_comments is null
-------------------------------------------------------------

Comments if any:
================



omments if any:
================


Any idea why it is printing it twice?

Thanks,

Faraz
 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      01-22-2004
Duke of Hazard wrote:
> I have this code:
> -----------------
>
> print MAIL "Comments if any:\n";
> print MAIL "================\n\n";
> print MAIL "$x_comments";
> print MAIL "\n\n";
>
> close (MAIL);
>
> Which produces this unexpected output when x_comments is null


What null? The text November-Uniform-Lima-Lima?
The number 0?
A binary value of \0x00?

> -------------------------------------------------------------
>
> Comments if any:
> ================
>
>
>
> omments if any:
> ================
>
>
> Any idea why it is printing it twice?


Well, the code you are showing to us won't print anything but an error
message about MAIL not being opened. What is your real code?

(Hint: your problem probably has nothing to do with those print statements
but with some 'interesting' logic in your program).

jue


 
Reply With Quote
 
 
 
 
Duke of Hazard
Guest
Posts: n/a
 
      01-22-2004
Here's the code pasted below. Everything works as it should, except
the last line seems to get printed twice.

################################################## #
# mailing faraz_hussainyahoo.com cc'ing $x_email1 #
################################################## #

$mail_prog = '/usr/sbin/sendmail -t' ;


if ($x_email1) {

open (MAIL, "|$mail_prog");
print MAIL "From: $r0\n";
print MAIL "To: $r0,$r1,$r2,$r3\n";
print MAIL "Cc: $x_email1\n";
print MAIL "Subject: ISRA - New member\n";
print MAIL "The following person has joined ISRA\n";
print MAIL "====================================\n\n";
print MAIL "$x_lastname, $x_firstname\n\n";

print MAIL "DOB, sex\n";
print MAIL "==========\n\n";
print MAIL "$x_dob, $x_sex\n\n";

print MAIL "Address 1\n";
print MAIL "==========\n\n";
print MAIL "$x_address1 \n $address2\n";

print MAIL "City, state and zip:\n";
print MAIL "====================\n\n";
print MAIL "$x_city ,$x_state ,$x_zip \n\n";

print MAIL "Home, work and cellphone\n";
print MAIL "========================\n\n";
print MAIL "$x_homephone , $x_workphone ,$x_cellphone \n\n";

print MAIL "With the following rating:\n";
print MAIL "==============================\n\n";
print MAIL "$x_rating\n\n";
print MAIL "The following contact information was provided:\n";
print MAIL "===============================================\n \n";
print MAIL "$x_email1, $x_email2\n\n";

print MAIL "Volunteer?\n";
print MAIL "==========\n\n";
print MAIL "$x_volunteer\n\n";

print MAIL "Comments if any:\n";
print MAIL "================\n\n";
print MAIL "$x_comments";
print MAIL "\n\n";

close (MAIL);
} # end of if statement

################################################## ################
################################################## ################
 
Reply With Quote
 
Brad Olin
Guest
Posts: n/a
 
      01-22-2004
On 22 Jan 2004 07:03:34 -0800, (Duke of Hazard)
wrote:

Your script is similar to a script I have. I think you could use a some
error management, an easer style, and a tip on email headers.

>Here's the code pasted below. Everything works as it should, except
>the last line seems to get printed twice.
>
>################################################# ##
># mailing faraz_hussainyahoo.com cc'ing $x_email1 #
>################################################# ##
>
>$mail_prog = '/usr/sbin/sendmail -t' ;
>
>
>if ($x_email1) {
>
>open (MAIL, "|$mail_prog");


If this open fails, which happens, then your script will fail and you
won't know it. Try this...

open MAIL, "|/usr/sbin/sendmail -t" or die "Can't open sendmail: $!\n";

You then go through each line with it's own print statement, nothing
wrong with this, but it is easer to follow/maintain/format if you...

print MAIL <<eof;
From: $r0
To: $r0,$r1,$r2,$r3
Cc: $x_email1
Subject: ISRA - New member

The following person has joined ISRA
====================================
<insert the rest of the body here>
eof
close MAIL or die "Can't close sendmail: $!/$?\n";
} # end of if

>print MAIL "From: $r0\n";
>print MAIL "To: $r0,$r1,$r2,$r3\n";
>print MAIL "Cc: $x_email1\n";
>print MAIL "Subject: ISRA - New member\n";
>print MAIL "The following person has joined ISRA\n";



Here I want to point out that there MUST be a blank line between the
last header and the body of the email. This may seem like I'm picking a
nit, but it's not really me... every email related program requires it
as the separator between header and body. This may well be what is
causing the problem you are looking for.



Brad
--
"He who asks is a fool for five minutes, but he who does not ask remains
a fool forever." Chinese proverb

Bradley W. Olin http://www.bwo1.com
 
Reply With Quote
 
nobull@mail.com
Guest
Posts: n/a
 
      01-23-2004
(Duke of Hazard) wrote in message news:< om>...
> Here's the code pasted below. Everything works as it should, except
> the last line seems to get printed twice.


[snip incomplete code]

Well, the code you are showing to us won't do anything because it's
all wrapped in an if with a condition that'll be undefined.

What is your real code?

(Hint: your problem probably has nothing to do with those print
statements but with some 'interesting' logic in your program).

Deja vu?

(Further hint: Got any forks?)

Please see the posting guidelines that are posted frequently in
comp.lang.perl.misc for advice on how to ask questions effectively in
technical newsgroups.

This newsgroup does not exist (see FAQ). Please do not start threads
here.
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unusual network setup due to hardware limitation =?Utf-8?B?UmVjb24=?= Wireless Networking 3 12-12-2005 03:27 PM
ICS unusual problem richardewing@gmail.com Wireless Networking 2 04-14-2005 09:35 AM
Unusual IPSEC routing issue Andrew Cisco 2 02-25-2005 12:08 PM
Unusual email bounce message Trent SC Computer Support 3 12-20-2004 05:15 PM
Hey, Please help, unusual problem with our email system. md Computer Support 2 04-06-2004 11:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57