[24350] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 6539 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 7 18:10:41 2004

Date: Fri, 7 May 2004 15:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 7 May 2004     Volume: 10 Number: 6539

Today's topics:
    Re: Using $1, $2 ... but don't know in which order <ittyspam@yahoo.com>
    Re: Using $1, $2 ... but don't know in which order <remorse@partners.org>
    Re: Using $1, $2 ... but don't know in which order <tassilo.parseval@rwth-aachen.de>
    Re: Using $1, $2 ... but don't know in which order <ittyspam@yahoo.com>
        Why is this simple script not sending email? (fastjack)
    Re: Why is this simple script not sending email? <ittyspam@yahoo.com>
    Re: Why is this simple script not sending email? (David Efflandt)
    Re: Why is this simple script not sending email? (Kevin Collins)
    Re: Why is this simple script not sending email? (Kevin Collins)
    Re: Why is this simple script not sending email? <emschwar@pobox.com>
    Re: Why is this simple script not sending email? (Kevin Collins)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 7 May 2004 15:00:28 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Using $1, $2 ... but don't know in which order
Message-Id: <20040507145829.P25082@dishwasher.cs.rpi.edu>

On Fri, 7 May 2004, Anno Siegel wrote:

> Tore Aursand  <tore@aursand.no> wrote in comp.lang.perl.misc:
> >       if ( defined $text && length $text ) {
>                            ^^
> Precedence problem here.

Funny, I was going to say there was a redundancy problem here.  Afterall,
if $text passes the length() test, won't it by definition also pass the
defined() test?  That is, no undef value can ever have a non-zero length,
can it?

Paul Lalli


------------------------------

Date: Fri, 07 May 2004 15:08:15 -0400
From: Richard Morse <remorse@partners.org>
Subject: Re: Using $1, $2 ... but don't know in which order
Message-Id: <remorse-C63EAF.15081507052004@plato.harvard.edu>

In article <20040507145829.P25082@dishwasher.cs.rpi.edu>,
 Paul Lalli <ittyspam@yahoo.com> wrote:

> On Fri, 7 May 2004, Anno Siegel wrote:
> 
> > Tore Aursand  <tore@aursand.no> wrote in comp.lang.perl.misc:
> > >       if ( defined $text && length $text ) {
> >                            ^^
> > Precedence problem here.
> 
> Funny, I was going to say there was a redundancy problem here.  Afterall,
> if $text passes the length() test, won't it by definition also pass the
> defined() test?  That is, no undef value can ever have a non-zero length,
> can it?

Yes, but if the code is running under warnings, trying to get length of 
$text will print a warning about using an uninitialized value.  Although 
it's just a warning, and doesn't actually hurt the program, it is ugly.  
So that's why you first test the definedness...

Ricy

-- 
Pukku


------------------------------

Date: Fri, 7 May 2004 21:09:25 +0200
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Using $1, $2 ... but don't know in which order
Message-Id: <2g2577F3l0upU1@uni-berlin.de>

Also sprach Paul Lalli:

> On Fri, 7 May 2004, Anno Siegel wrote:
> 
>> Tore Aursand  <tore@aursand.no> wrote in comp.lang.perl.misc:
>> >       if ( defined $text && length $text ) {
>>                            ^^
>> Precedence problem here.
> 
> Funny, I was going to say there was a redundancy problem here.  Afterall,
> if $text passes the length() test, won't it by definition also pass the
> defined() test?  That is, no undef value can ever have a non-zero length,
> can it?

The preliminary test for definedness might be there in order to avoid a
"Use of uninitialized value" warning. Functionally, it is not necessary.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


------------------------------

Date: Fri, 7 May 2004 15:24:57 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Using $1, $2 ... but don't know in which order
Message-Id: <20040507152416.J25082@dishwasher.cs.rpi.edu>

On Fri, 7 May 2004, Richard Morse wrote:

> In article <20040507145829.P25082@dishwasher.cs.rpi.edu>,
>  Paul Lalli <ittyspam@yahoo.com> wrote:
>
> > On Fri, 7 May 2004, Anno Siegel wrote:
> >
> > > Tore Aursand  <tore@aursand.no> wrote in comp.lang.perl.misc:
> > > >       if ( defined $text && length $text ) {
> > >                            ^^
> > > Precedence problem here.
> >
> > Funny, I was going to say there was a redundancy problem here.  Afterall,
> > if $text passes the length() test, won't it by definition also pass the
> > defined() test?  That is, no undef value can ever have a non-zero length,
> > can it?
>
> Yes, but if the code is running under warnings, trying to get length of
> $text will print a warning about using an uninitialized value.  Although
> it's just a warning, and doesn't actually hurt the program, it is ugly.
> So that's why you first test the definedness...


Ahh, yes, I see that now.  I hadn't thought of the warning issue.  Thanks
for clarifying for me.

Paul Lalli


------------------------------

Date: 7 May 2004 11:16:11 -0700
From: robnhood00@aol.com (fastjack)
Subject: Why is this simple script not sending email?
Message-Id: <8696c0f6.0405071016.4711f721@posting.google.com>

#My email is in the "To: " line.  just not listed below for spam reasons.

#!/usr/bin/perl

$mailprog = '/usr/lib/sendmail -i -t';
open(MAIL,"|$mailprog");

    print MAIL "To: myemail@mydomain.com\n";
    print MAIL "From: test@test.com (Test )\n";
    # Add Ability to send HTML
    print MAIL "Content-type: text/html\n";

    # Check for Message Subject
    print MAIL "Subject: Test\n\n";

    print MAIL "This is a test\n\n";
 close (MAIL);
print "Content-type: text/html\n\n";
print "<html><h1>The Email has been sent</h1></html>\n";


------------------------------

Date: Fri, 7 May 2004 14:44:33 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Why is this simple script not sending email?
Message-Id: <20040507144030.Q25082@dishwasher.cs.rpi.edu>

On Fri, 7 May 2004, fastjack wrote:

> #My email is in the "To: " line.  just not listed below for spam reasons.
>
> #!/usr/bin/perl
use strict;
use warnings;

>
> $mailprog = '/usr/lib/sendmail -i -t';
my $mailprog = '/usr/lib/sendmail -i -t';

> open(MAIL,"|$mailprog");

open MAIL, "|$mailprog" or die "Cannot start mail program: $!";

>
>     print MAIL "To: myemail@mydomain.com\n";
>     print MAIL "From: test@test.com (Test )\n";

I'm not convinced that's an acceptable header, though I could be wrong.
print MAIL "From: Test <test@test.com>\n";


>     # Add Ability to send HTML
>     print MAIL "Content-type: text/html\n";
>
>     # Check for Message Subject
>     print MAIL "Subject: Test\n\n";
>
>     print MAIL "This is a test\n\n";
>  close (MAIL);
> print "Content-type: text/html\n\n";
> print "<html><h1>The Email has been sent</h1></html>\n";

If this revised script doesn't die at the open line, then there's
something wrong with the information you're sending to sendmail.  If it
does, figure out what to do based on the error message.  (If you're
running this via a webserver, as it appears, you will need to check the
server logs and/or run the script on the command line to see the error
message).

Paul Lalli


------------------------------

Date: Fri, 7 May 2004 18:47:33 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Why is this simple script not sending email?
Message-Id: <slrnc9nme4.94d.efflandt@typhoon.xnet.com>

On 7 May 2004 11:16:11 -0700, fastjack <robnhood00@aol.com> wrote:
> #My email is in the "To: " line.  just not listed below for spam reasons.

One reason your script does not work is because "@domain" and "@test" are 
list variables when in enclosed in double quotes, so your addresses are 
invalid.  You either need to escape the "\@" or use single quotes around 
that part of it like 'To: myemail@mydomain.com'."\n"

However, you also fail to test your open() and close() to see if there are 
any other problems.

> #!/usr/bin/perl
> 
> $mailprog = '/usr/lib/sendmail -i -t';
> open(MAIL,"|$mailprog");
> 
>     print MAIL "To: myemail@mydomain.com\n";
>     print MAIL "From: test@test.com (Test )\n";
>     # Add Ability to send HTML
>     print MAIL "Content-type: text/html\n";
> 
>     # Check for Message Subject
>     print MAIL "Subject: Test\n\n";
> 
>     print MAIL "This is a test\n\n";
>  close (MAIL);
> print "Content-type: text/html\n\n";
> print "<html><h1>The Email has been sent</h1></html>\n";


-- 
David Efflandt - All spam ignored  http://www.de-srv.com/


------------------------------

Date: Fri, 07 May 2004 19:12:52 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Why is this simple script not sending email?
Message-Id: <slrnc9nnte.99i.spamtotrash@doom.unix-guy.com>

In article <8696c0f6.0405071016.4711f721@posting.google.com>, fastjack wrote:
> #My email is in the "To: " line.  just not listed below for spam reasons.
> 
> #!/usr/bin/perl
> 
> $mailprog = '/usr/lib/sendmail -i -t';
> open(MAIL,"|$mailprog");

Why not try:
  open(MAIL,"|$mailprog") || die "can't open $mailprog: $!";

And sense this appears to be CGI, add the following BEFORE the above line:

  use CGI::Carp qw(fatalsToBrowser);

> 
>     print MAIL "To: myemail@mydomain.com\n";
>     print MAIL "From: test@test.com (Test )\n";
>     # Add Ability to send HTML
>     print MAIL "Content-type: text/html\n";
> 
>     # Check for Message Subject
>     print MAIL "Subject: Test\n\n";
> 
>     print MAIL "This is a test\n\n";
>  close (MAIL);
> print "Content-type: text/html\n\n";
> print "<html><h1>The Email has been sent</h1></html>\n";

Do you have access to the mail logs? Do you know for certain that sendmail is
in the location you have specified?

Kevin


------------------------------

Date: Fri, 07 May 2004 21:02:56 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Why is this simple script not sending email?
Message-Id: <slrnc9nuc0.99i.spamtotrash@doom.unix-guy.com>

In article <slrnc9nme4.94d.efflandt@typhoon.xnet.com>, David Efflandt wrote:
> On 7 May 2004 11:16:11 -0700, fastjack <robnhood00@aol.com> wrote:
>> #My email is in the "To: " line.  just not listed below for spam reasons.
> 
> One reason your script does not work is because "@domain" and "@test" are 
> list variables when in enclosed in double quotes, so your addresses are 
> invalid.  You either need to escape the "\@" or use single quotes around 
> that part of it like 'To: myemail@mydomain.com'."\n"
> 
> However, you also fail to test your open() and close() to see if there are 
> any other problems.

Not to sound like a smartass, but why would you test a close()? I have never
thought about it before I read this post... If it doesn't close with close(),
it definitely will on program termination.

>> #!/usr/bin/perl
>> 
>> $mailprog = '/usr/lib/sendmail -i -t';
>> open(MAIL,"|$mailprog");
>> 
>>     print MAIL "To: myemail@mydomain.com\n";
>>     print MAIL "From: test@test.com (Test )\n";
>>     # Add Ability to send HTML
>>     print MAIL "Content-type: text/html\n";
>> 
>>     # Check for Message Subject
>>     print MAIL "Subject: Test\n\n";
>> 
>>     print MAIL "This is a test\n\n";
>>  close (MAIL);
>> print "Content-type: text/html\n\n";
>> print "<html><h1>The Email has been sent</h1></html>\n";
> 
> 


------------------------------

Date: Fri, 07 May 2004 15:36:25 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Why is this simple script not sending email?
Message-Id: <etosmebgbs6.fsf@fc.hp.com>

spamtotrash@toomuchfiction.com (Kevin Collins) writes:
> Not to sound like a smartass, but why would you test a close()? I have never
> thought about it before I read this post... If it doesn't close with close(),
> it definitely will on program termination.

close() can fail in a number of odd, but potentially care-about-able
cases.  If a filehandle's buffer contains more data than will fit on
the disk when it's flush()ed, the close() can fail.  If the filehandle
is a socket endpoint, bad things can happen there, too.  Anyway, it
doesn't really hurt anything, and it can give you more information on
a failure if you use it, so why not?

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


------------------------------

Date: Fri, 07 May 2004 21:41:47 GMT
From: spamtotrash@toomuchfiction.com (Kevin Collins)
Subject: Re: Why is this simple script not sending email?
Message-Id: <slrnc9o0kr.bgd.spamtotrash@doom.unix-guy.com>

In article <etosmebgbs6.fsf@fc.hp.com>, Eric Schwartz wrote:
> spamtotrash@toomuchfiction.com (Kevin Collins) writes:
>> Not to sound like a smartass, but why would you test a close()? I have never
>> thought about it before I read this post... If it doesn't close with close(),
>> it definitely will on program termination.
> 
> close() can fail in a number of odd, but potentially care-about-able
> cases.  If a filehandle's buffer contains more data than will fit on
> the disk when it's flush()ed, the close() can fail.  If the filehandle
> is a socket endpoint, bad things can happen there, too.  Anyway, it
> doesn't really hurt anything, and it can give you more information on
> a failure if you use it, so why not?

Ok, those sound like intelligent reasons to me...

Kevin


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6539
***************************************


home help back first fref pref prev next nref lref last post