[30223] in Perl-Users-Digest
Perl-Users Digest, Issue: 1466 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 22 17:07:46 2008
Date: Tue, 22 Apr 2008 14:07:35 -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 Tue, 22 Apr 2008 Volume: 11 Number: 1466
Today's topics:
Regx to remove all characters after a match <squash@peoriadesignweb.com>
Re: Regx to remove all characters after a match <someone@example.com>
Re: Regx to remove all characters after a match <eric-amick@comcast.net>
Re: Regx to remove all characters after a match <noreply@gunnar.cc>
Re: Regx to remove all characters after a match <abigail@abigail.be>
Re: Regx to remove all characters after a match <noreply@gunnar.cc>
Selecting Default Gateway <XXjbhuntxx@white-star.com>
Re: Selecting Default Gateway <abigail@abigail.be>
Re: Selecting Default Gateway <XXjbhuntxx@white-star.com>
Re: Selecting Default Gateway <abigail@abigail.be>
Re: Selecting Default Gateway <XXjbhuntxx@white-star.com>
Send a PHP array to a Perl script techusky@gmail.com
Re: Send a PHP array to a Perl script <simon.chao@fmr.com>
Re: Send a PHP array to a Perl script <sopan.shewale@gmail.com>
sending email from perl using a pipe and mailx <bl8n8r@gmail.com>
Re: sending email from perl using a pipe and mailx <1usa@llenroc.ude.invalid>
Re: sending email from perl using a pipe and mailx <szrRE@szromanMO.comVE>
Re: sending email from perl using a pipe and mailx <glennj@ncf.ca>
Re: sending email from perl using a pipe and mailx <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 17 Apr 2008 20:23:23 -0700 (PDT)
From: Duke of Hazard <squash@peoriadesignweb.com>
Subject: Regx to remove all characters after a match
Message-Id: <302828b1-d7a7-420b-8c12-c9070f36228e@59g2000hsb.googlegroups.com>
I can not figure out why this is not printing just 123:
$name = "123\n456\n789";
$name =~ s/\n.*//;
print $name;
which outputs:
123
789
If I write it in php using preg_replace , it works!
------------------------------
Date: Fri, 18 Apr 2008 04:30:16 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Regx to remove all characters after a match
Message-Id: <stVNj.222$PM5.47@edtnps92>
Duke of Hazard wrote:
> I can not figure out why this is not printing just 123:
>
> $name = "123\n456\n789";
>
> $name =~ s/\n.*//;
>
> print $name;
>
> which outputs:
>
> 123
> 789
That is because . matches any character *except* newline. If you want
it to match a newline as well then you have to use the /s option:
$name =~ s/\n.*//s;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Fri, 18 Apr 2008 00:37:22 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: Regx to remove all characters after a match
Message-Id: <tl8g04pevvn0oamjtguustls32rilt6eq4@4ax.com>
On Thu, 17 Apr 2008 20:23:23 -0700 (PDT), Duke of Hazard
<squash@peoriadesignweb.com> wrote:
>I can not figure out why this is not printing just 123:
>
>$name = "123\n456\n789";
>
>$name =~ s/\n.*//;
>
>print $name;
>
>which outputs:
>
>123
>789
>
>If I write it in php using preg_replace , it works!
By default, '.' in Perl regexes does not match newline. If you want it
to match newline, use
$name =~ s/\n.*//s;
I don't know PHP, but it surprises me that it handles that case
differently.
--
Eric Amick
Columbia, MD
------------------------------
Date: Fri, 18 Apr 2008 10:12:43 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regx to remove all characters after a match
Message-Id: <66r3c2F2h2crbU1@mid.individual.net>
Eric Amick wrote:
> On Thu, 17 Apr 2008 20:23:23 -0700 (PDT), Duke of Hazard
> <squash@peoriadesignweb.com> wrote:
>
>> I can not figure out why this is not printing just 123:
>>
>> $name = "123\n456\n789";
>>
>> $name =~ s/\n.*//;
>>
>> print $name;
>>
>> which outputs:
>>
>> 123
>> 789
>>
>> If I write it in php using preg_replace , it works!
>
> By default, '.' in Perl regexes does not match newline. If you want it
> to match newline, use
>
> $name =~ s/\n.*//s;
>
> I don't know PHP, but it surprises me that it handles that case
> differently.
A bug in PHP?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 18 Apr 2008 09:45:28 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Regx to remove all characters after a match
Message-Id: <slrng0grdo.oar.abigail@alexandra.abigail.be>
_
Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on VCCCXLIV September
MCMXCIII in <URL:news:66r3c2F2h2crbU1@mid.individual.net>:
~~ Eric Amick wrote:
~~ > On Thu, 17 Apr 2008 20:23:23 -0700 (PDT), Duke of Hazard
~~ > <squash@peoriadesignweb.com> wrote:
~~ >
~~ >> I can not figure out why this is not printing just 123:
~~ >>
~~ >> $name = "123\n456\n789";
~~ >>
~~ >> $name =~ s/\n.*//;
~~ >>
~~ >> print $name;
~~ >>
~~ >> which outputs:
~~ >>
~~ >> 123
~~ >> 789
~~ >>
~~ >> If I write it in php using preg_replace , it works!
~~ >
~~ > By default, '.' in Perl regexes does not match newline. If you want it
~~ > to match newline, use
~~ >
~~ > $name =~ s/\n.*//s;
~~ >
~~ > I don't know PHP, but it surprises me that it handles that case
~~ > differently.
~~
~~ A bug in PHP?
It would do what the OP intended in Perl6 as well.
Abigail
--
tie $" => A; $, = " "; $\ = "\n"; @a = ("") x 2; print map {"@a"} 1 .. 4;
sub A::TIESCALAR {bless \my $A => A} # Yet Another silly JAPH by Abigail
sub A::FETCH {@q = qw /Just Another Perl Hacker/ unless @q; shift @q}
------------------------------
Date: Fri, 18 Apr 2008 13:43:10 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regx to remove all characters after a match
Message-Id: <66rfmmF2logsoU1@mid.individual.net>
Abigail wrote:
> Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on VCCCXLIV September
> MCMXCIII in <URL:news:66r3c2F2h2crbU1@mid.individual.net>:
> ~~ Eric Amick wrote:
> ~~ > On Thu, 17 Apr 2008 20:23:23 -0700 (PDT), Duke of Hazard
> ~~ > <squash@peoriadesignweb.com> wrote:
> ~~ >
> ~~ >> I can not figure out why this is not printing just 123:
> ~~ >>
> ~~ >> $name = "123\n456\n789";
> ~~ >>
> ~~ >> $name =~ s/\n.*//;
> ~~ >>
> ~~ >> print $name;
> ~~ >>
> ~~ >> which outputs:
> ~~ >>
> ~~ >> 123
> ~~ >> 789
> ~~ >>
> ~~ >> If I write it in php using preg_replace , it works!
> ~~ >
> ~~ > By default, '.' in Perl regexes does not match newline. If you want it
> ~~ > to match newline, use
> ~~ >
> ~~ > $name =~ s/\n.*//s;
> ~~ >
> ~~ > I don't know PHP, but it surprises me that it handles that case
> ~~ > differently.
> ~~
> ~~ A bug in PHP?
>
> It would do what the OP intended in Perl6 as well.
Maybe so, but the PHP docs say:
".
match any character except newline (by default)"
And still:
$ cat test.php
#!/usr/bin/php
<?php echo preg_replace('/\n.*/', '', "123\n456\n789") ?>
$ ./test.php
Content-type: text/html
X-Powered-By: PHP/4.3.3
123
$
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 18 Apr 2008 17:45:30 GMT
From: Cosmic Cruizer <XXjbhuntxx@white-star.com>
Subject: Selecting Default Gateway
Message-Id: <Xns9A846D59DF7E0ccruizermydejacom@207.115.17.102>
I'm using IO::Socket to test a port on a remote server on the Internet from
our intranet. I need to make sure I go through the same proxy server each
time. I believe I can direct my port probe to use the proxy server as the
default gateway, which would solve my problem. From what I can tell,
IO::Socket does not allow me to do that.
Is there a module that will let me enter a value for a default gateway so I
can dictate which proxy server I want to pass through?
------------------------------
Date: 18 Apr 2008 20:05:06 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Selecting Default Gateway
Message-Id: <slrng0hvni.oar.abigail@alexandra.abigail.be>
_
Cosmic Cruizer (XXjbhuntxx@white-star.com) wrote on VCCCXLIV September
MCMXCIII in <URL:news:Xns9A846D59DF7E0ccruizermydejacom@207.115.17.102>:
-- I'm using IO::Socket to test a port on a remote server on the Internet from
-- our intranet. I need to make sure I go through the same proxy server each
-- time. I believe I can direct my port probe to use the proxy server as the
-- default gateway, which would solve my problem. From what I can tell,
-- IO::Socket does not allow me to do that.
Sure it does. If you are using a proxy on server proxy.example.com, you're
making a socket connection to proxy.example.com - not to whatever server
you are trying to reach through the proxy.
-- Is there a module that will let me enter a value for a default gateway so I
-- can dictate which proxy server I want to pass through?
Maybe.
You aren't telling us what the protocol is you are using. If you're trying
to connect an HTTP server, there are several modules available that can
work through a proxy server.
But if it's some other protocol, you may be out of luck. Then you have to
talk that protocol yourself - but you would have to do that with IO::Socket
anyway.
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: Fri, 18 Apr 2008 21:16:50 GMT
From: Cosmic Cruizer <XXjbhuntxx@white-star.com>
Subject: Re: Selecting Default Gateway
Message-Id: <Xns9A84912E6A70Cccruizermydejacom@207.115.33.102>
Abigail <abigail@abigail.be> wrote in
news:slrng0hvni.oar.abigail@alexandra.abigail.be:
> _
> Cosmic Cruizer (XXjbhuntxx@white-star.com) wrote on VCCCXLIV September
> MCMXCIII in
> <URL:news:Xns9A846D59DF7E0ccruizermydejacom@207.115.17.102>: -- I'm
> using IO::Socket to test a port on a remote server on the Internet
> from -- our intranet. I need to make sure I go through the same proxy
> server each -- time. I believe I can direct my port probe to use the
> proxy server as the -- default gateway, which would solve my problem.
> From what I can tell, -- IO::Socket does not allow me to do that.
>
>
> Sure it does. If you are using a proxy on server proxy.example.com,
> you're making a socket connection to proxy.example.com - not to
> whatever server you are trying to reach through the proxy.
>
>
> -- Is there a module that will let me enter a value for a default
> gateway so I -- can dictate which proxy server I want to pass
> through?
>
>
> Maybe.
>
> You aren't telling us what the protocol is you are using. If you're
> trying to connect an HTTP server, there are several modules available
> that can work through a proxy server.
>
> But if it's some other protocol, you may be out of luck. Then you have
> to talk that protocol yourself - but you would have to do that with
> IO::Socket anyway.
>
>
> Abigail
So for this example, let's say I have the folowing:
Internet destination is www.internet.com port 80
My server is 10.10.10.5
The proxy servers are 10.10.10.50 and 10.10.20.50.
I want to go from my server, through the proxy at 10.10.20.50 to port 80
on www.internet.com. Port 25 is another port I might want to touch on the
Internet server.
------------------------------
Date: 19 Apr 2008 22:09:36 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Selecting Default Gateway
Message-Id: <slrng0krd0.veg.abigail@alexandra.abigail.be>
_
Cosmic Cruizer (XXjbhuntxx@white-star.com) wrote on VCCCXLIV September
MCMXCIII in <URL:news:Xns9A84912E6A70Cccruizermydejacom@207.115.33.102>:
// Abigail <abigail@abigail.be> wrote in
// news:slrng0hvni.oar.abigail@alexandra.abigail.be:
//
// > _
// > Cosmic Cruizer (XXjbhuntxx@white-star.com) wrote on VCCCXLIV September
// > MCMXCIII in
// > <URL:news:Xns9A846D59DF7E0ccruizermydejacom@207.115.17.102>: -- I'm
// > using IO::Socket to test a port on a remote server on the Internet
// > from -- our intranet. I need to make sure I go through the same proxy
// > server each -- time. I believe I can direct my port probe to use the
// > proxy server as the -- default gateway, which would solve my problem.
// > From what I can tell, -- IO::Socket does not allow me to do that.
// >
// >
// > Sure it does. If you are using a proxy on server proxy.example.com,
// > you're making a socket connection to proxy.example.com - not to
// > whatever server you are trying to reach through the proxy.
// >
// >
// > -- Is there a module that will let me enter a value for a default
// > gateway so I -- can dictate which proxy server I want to pass
// > through?
// >
// >
// > Maybe.
// >
// > You aren't telling us what the protocol is you are using. If you're
// > trying to connect an HTTP server, there are several modules available
// > that can work through a proxy server.
// >
// > But if it's some other protocol, you may be out of luck. Then you have
// > to talk that protocol yourself - but you would have to do that with
// > IO::Socket anyway.
// >
// >
// > Abigail
//
// So for this example, let's say I have the folowing:
//
// Internet destination is www.internet.com port 80
// My server is 10.10.10.5
// The proxy servers are 10.10.10.50 and 10.10.20.50.
//
// I want to go from my server, through the proxy at 10.10.20.50 to port 80
// on www.internet.com.
I'd use LWP::Simple.
// Port 25 is another port I might want to touch on the
// Internet server.
What's an "Internet server"?
Abigail
--
perl -wle 'eval {die ["Just another Perl Hacker"]}; print ${$@}[$#{@${@}}]'
------------------------------
Date: Mon, 21 Apr 2008 00:21:21 GMT
From: Cosmic Cruizer <XXjbhuntxx@white-star.com>
Subject: Re: Selecting Default Gateway
Message-Id: <Xns9A86B07568722ccruizermydejacom@207.115.33.102>
Abigail <abigail@abigail.be> wrote in
news:slrng0krd0.veg.abigail@alexandra.abigail.be:
> _
> Cosmic Cruizer (XXjbhuntxx@white-star.com) wrote on VCCCXLIV September
> MCMXCIII in
> <URL:news:Xns9A84912E6A70Cccruizermydejacom@207.115.33.102>: //
> Abigail <abigail@abigail.be> wrote in //
> news:slrng0hvni.oar.abigail@alexandra.abigail.be: //
> // > _
> // > Cosmic Cruizer (XXjbhuntxx@white-star.com) wrote on VCCCXLIV
> September // > MCMXCIII in
> // > <URL:news:Xns9A846D59DF7E0ccruizermydejacom@207.115.17.102>: --
> I'm // > using IO::Socket to test a port on a remote server on the
> Internet // > from -- our intranet. I need to make sure I go through
> the same proxy // > server each -- time. I believe I can direct my
> port probe to use the // > proxy server as the -- default gateway,
> which would solve my problem. // > From what I can tell, --
> IO::Socket does not allow me to do that. // >
> // >
> // > Sure it does. If you are using a proxy on server
> proxy.example.com, // > you're making a socket connection to
> proxy.example.com - not to // > whatever server you are trying to
> reach through the proxy. // >
> // >
> // > -- Is there a module that will let me enter a value for a
> default // > gateway so I -- can dictate which proxy server I want to
> pass // > through?
> // >
> // >
> // > Maybe.
> // >
> // > You aren't telling us what the protocol is you are using. If
> you're // > trying to connect an HTTP server, there are several
> modules available // > that can work through a proxy server.
> // >
> // > But if it's some other protocol, you may be out of luck. Then you
> have // > to talk that protocol yourself - but you would have to do
> that with // > IO::Socket anyway.
> // >
> // >
> // > Abigail
> //
> // So for this example, let's say I have the folowing:
> //
> // Internet destination is www.internet.com port 80
> // My server is 10.10.10.5
> // The proxy servers are 10.10.10.50 and 10.10.20.50.
> //
> // I want to go from my server, through the proxy at 10.10.20.50 to
> port 80 // on www.internet.com.
>
>
> I'd use LWP::Simple.
>
>
> // Port 25 is another port I might want to touch
> on the // Internet server.
>
>
> What's an "Internet server"?
>
>
>
> Abigail
Looks like you got me pointed in the right direction. From what I'm
reading, LWP::UserAgent is what I need/want.
Thank you very much Abigail!
------------------------------
Date: Mon, 21 Apr 2008 12:57:08 -0700 (PDT)
From: techusky@gmail.com
Subject: Send a PHP array to a Perl script
Message-Id: <a57ba445-4f27-45a8-bd3d-278a169af2a2@m3g2000hsc.googlegroups.com>
First off, I am not sure where exactly to post this, so I'm posting to
both php.general and here...
My general problem is that I am wondering if there is a(n effective)
way to send an array from a PHP script to a Perl script. I am
developing a simple Perl script to handle automated e-mails from my
website (which is written exclusively in PHP). I would ordinarily just
stick with PHP as far as e-mailing is concerned, but I have found it
to be much more a pain trying to connect to my Gmail account via
sockets to send e-mail; the Perl route is much simpler in my opinion.
I have a form on my website that will let me specify to which users
from my site I would like to send the e-mail. Upon submitting the
form, the PHP script parses the e-mail addresses from
$_POST['user_emails'] and puts them into an array. Then what happens
is that I do something to the effect of:
foreach($user_emails as $user) {
[some code omitted here that generates the perl script]
shell_exec("perl \"./email.user.pl\"");
}
Essentially, what this does is sends out individual e-mails to each
user (it takes roughly 5-8 seconds for it to send out one e-mail, so
you can imagine if I try to send to 100 users that it takes quite a
while). But we all know that you can send a single e-mail to many
different people at the same time... This is why I am trying to send
PHP's array to my Perl script, because I could then easily add each
element in the array to one e-mail.
Any ideas? Sorry if my problem isn't clear (or if there is some
stupidly simple solution I am not thinking of... I'm not that fluent
in Perl yet).
------------------------------
Date: Mon, 21 Apr 2008 13:03:33 -0700 (PDT)
From: nolo contendere <simon.chao@fmr.com>
Subject: Re: Send a PHP array to a Perl script
Message-Id: <3be14f98-0723-42b6-8a1a-019e9b474c15@y21g2000hsf.googlegroups.com>
On Apr 21, 3:57=A0pm, techu...@gmail.com wrote:
> First off, I am not sure where exactly to post this, so I'm posting to
> both php.general and here...
>
> My general problem is that I am wondering if there is a(n effective)
> way to send an array from a PHP script to a Perl script. I am
> developing a simple Perl script to handle automated e-mails from my
> website (which is written exclusively in PHP). I would ordinarily just
> stick with PHP as far as e-mailing is concerned, but I have found it
> to be much more a pain trying to connect to my Gmail account via
> sockets to send e-mail; the Perl route is much simpler in my opinion.
>
> I have a form on my website that will let me specify to which users
> from my site I would like to send the e-mail. Upon submitting the
> form, the PHP script parses the e-mail addresses from
> $_POST['user_emails'] and puts them into an array. Then what happens
> is that I do something to the effect of:
>
> foreach($user_emails as $user) {
> [some code omitted here that generates the perl script]
> shell_exec("perl \"./email.user.pl\"");
>
> }
>
> Essentially, what this does is sends out individual e-mails to each
> user (it takes roughly 5-8 seconds for it to send out one e-mail, so
> you can imagine if I try to send to 100 users that it takes quite a
> while). But we all know that you can send a single e-mail to many
> different people at the same time... This is why I am trying to send
> PHP's array to my Perl script, because I could then easily add each
> element in the array to one e-mail.
>
> Any ideas? Sorry if my problem isn't clear (or if there is some
> stupidly simple solution I am not thinking of... I'm not that fluent
> in Perl yet).
You could build a string from your PHP's array contents, joined by
whatever delimiter (it should show up in the email addresses), and
then pass that to the Perl script. Within the Perl script, split the
string to get your individual email addresses back. There are a number
of Mail modules for Perl--I know of at least one that takes comma
separated emails (Mail::Sender, I think). Also, you could open a pipe
to Unix's mailx, which I think takes space delimited email addresses.
HTH
------------------------------
Date: Mon, 21 Apr 2008 13:43:14 -0700 (PDT)
From: "sopan.shewale@gmail.com" <sopan.shewale@gmail.com>
Subject: Re: Send a PHP array to a Perl script
Message-Id: <cb5b9f62-697a-4b20-9b80-a94514f64357@w1g2000prd.googlegroups.com>
Hi,
I think instead of trying to send mail through form/action itself -
try following:
[1]. Collect the mail details in some file on the server in some
directory (call it mailq). Each form submit will create the mail file
under mailq. So your Browser user do not have to wait till your mails
are delivered - the speed is increased.
[2]. Write the daemon or script (use Perl or any other language) to
pick up the files from mailq, deliver the mails and clean those files
once you are done.
This will helps to remove issues because of PHP/Perl integration or
running processes/scripts together.
Also helps to increase the speed of your application.
--sopan shewale
http://sopanshewale.blogspot.com
On Apr 21, 12:57 pm, techu...@gmail.com wrote:
> First off, I am not sure where exactly to post this, so I'm posting to
> both php.general and here...
>
> My general problem is that I am wondering if there is a(n effective)
> way to send an array from a PHP script to a Perl script. I am
> developing a simple Perl script to handle automated e-mails from my
> website (which is written exclusively in PHP). I would ordinarily just
> stick with PHP as far as e-mailing is concerned, but I have found it
> to be much more a pain trying to connect to my Gmail account via
> sockets to send e-mail; the Perl route is much simpler in my opinion.
>
> I have a form on my website that will let me specify to which users
> from my site I would like to send the e-mail. Upon submitting the
> form, the PHP script parses the e-mail addresses from
> $_POST['user_emails'] and puts them into an array. Then what happens
> is that I do something to the effect of:
>
> foreach($user_emails as $user) {
> [some code omitted here that generates the perl script]
> shell_exec("perl \"./email.user.pl\"");
>
> }
>
> Essentially, what this does is sends out individual e-mails to each
> user (it takes roughly 5-8 seconds for it to send out one e-mail, so
> you can imagine if I try to send to 100 users that it takes quite a
> while). But we all know that you can send a single e-mail to many
> different people at the same time... This is why I am trying to send
> PHP's array to my Perl script, because I could then easily add each
> element in the array to one e-mail.
>
> Any ideas? Sorry if my problem isn't clear (or if there is some
> stupidly simple solution I am not thinking of... I'm not that fluent
> in Perl yet).
------------------------------
Date: Fri, 18 Apr 2008 07:05:38 -0700 (PDT)
From: bl8n8r <bl8n8r@gmail.com>
Subject: sending email from perl using a pipe and mailx
Message-Id: <453ccec8-946e-48ea-ae92-827b8b5d0461@59g2000hsb.googlegroups.com>
#!/usr/bin/perl
# the main user to send the email to
$recip = 'mainuser@domain.org';
# a comma separated list of users to CC the email too
$cclist = 'ccuser1@domain.org,ccuser2@domain.org';
# open a pipe to the mailx utility and feed it a subject along with
# recipients and the cclist
open (FI, "|/usr/bin/mailx -s 'TEST: New email message' $recip -c
$cclist");
# send the body of the email message and close.
# note: the email is not sent until the pipe is closed.
printf (FI "blah\nblah blah\n");
close (FI);
------------------------------
Date: Fri, 18 Apr 2008 14:15:49 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: sending email from perl using a pipe and mailx
Message-Id: <Xns9A8468681763Basu1cornelledu@127.0.0.1>
bl8n8r <bl8n8r@gmail.com> wrote in
news:453ccec8-946e-48ea-ae92-827b8b5d0461@
59g2000hsb.googlegroups.com
:
> #!/usr/bin/perl
>
> # the main user to send the email to
> $recip = 'mainuser@domain.org';
>
> # a comma separated list of users to CC the email too
> $cclist = 'ccuser1@domain.org,ccuser2@domain.org';
>
> # open a pipe to the mailx utility and feed it a subject along
> with # recipients and the cclist
> open (FI, "|/usr/bin/mailx -s 'TEST: New email message' $recip -c
> $cclist");
>
> # send the body of the email message and close.
> # note: the email is not sent until the pipe is closed.
> printf (FI "blah\nblah blah\n");
> close (FI);
Do you have a question?
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Fri, 18 Apr 2008 11:40:36 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: sending email from perl using a pipe and mailx
Message-Id: <fuapv50oft@news4.newsguy.com>
A. Sinan Unur wrote:
> bl8n8r <bl8n8r@gmail.com> wrote in
> news:453ccec8-946e-48ea-ae92-827b8b5d0461@
> 59g2000hsb.googlegroups.com
>>
>
>> #!/usr/bin/perl
>>
>> # the main user to send the email to
>> $recip = 'mainuser@domain.org';
>>
>> # a comma separated list of users to CC the email too
>> $cclist = 'ccuser1@domain.org,ccuser2@domain.org';
>>
>> # open a pipe to the mailx utility and feed it a subject along
>> with # recipients and the cclist
>> open (FI, "|/usr/bin/mailx -s 'TEST: New email message' $recip -c
>> $cclist");
>>
>> # send the body of the email message and close.
>> # note: the email is not sent until the pipe is closed.
>> printf (FI "blah\nblah blah\n");
>> close (FI);
>
> Do you have a question?
Why assume everything that is posted is always going to be a question?
Looks to me like someone was just sharing some code they had written. It
may not be the most complex of programs, but hey, everyone's gotta'
start somewhere.
--
szr
------------------------------
Date: 18 Apr 2008 19:55:02 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: sending email from perl using a pipe and mailx
Message-Id: <slrng0hv4n.kta.glennj@smeagol.ncf.ca>
At 2008-04-18 10:05AM, "bl8n8r" wrote:
> #!/usr/bin/perl
>
> # the main user to send the email to
> $recip = 'mainuser@domain.org';
>
> # a comma separated list of users to CC the email too
> $cclist = 'ccuser1@domain.org,ccuser2@domain.org';
>
> # open a pipe to the mailx utility and feed it a subject along with
> # recipients and the cclist
> open (FI, "|/usr/bin/mailx -s 'TEST: New email message' $recip -c
> $cclist");
>
> # send the body of the email message and close.
> # note: the email is not sent until the pipe is closed.
> printf (FI "blah\nblah blah\n");
> close (FI);
If you're looking for feedback:
#!/usr/bin/perl
use strict;
use warnings;
my $to = 'mainuser@domain.org';
my $cc = 'ccuser1@domain.org,ccuser2@domain.org';
my $subj = 'TEST: New email message';
open my $pipe, '|-', '/usr/bin/mailx', '-s', $subj, '-c', $cc, $to
or die "can't open pipe to mailx: $!\n";
print $pipe $body;
close $pipe;
die "mailx exited with a non-zero status: $?\n" if $?;
--
Glenn Jackman
"If there is anything the nonconformist hates worse than a conformist,
it's another nonconformist who doesn't conform to the prevailing
standard of nonconformity." -- Bill Vaughan
------------------------------
Date: Fri, 18 Apr 2008 20:49:34 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: sending email from perl using a pipe and mailx
Message-Id: <t42i04di58h0ck21hjg147rp6olj9allgo@4ax.com>
bl8n8r <bl8n8r@gmail.com> wrote:
>#!/usr/bin/perl
Missing
use strict;
use warnings;
># the main user to send the email to
>$recip = 'mainuser@domain.org';
>
># a comma separated list of users to CC the email too
>$cclist = 'ccuser1@domain.org,ccuser2@domain.org';
>
># open a pipe to the mailx utility and feed it a subject along with
># recipients and the cclist
>open (FI, "|/usr/bin/mailx -s 'TEST: New email message' $recip -c
>$cclist");
Missing error handling.
Would be better to use 3-argument form of open.
># send the body of the email message and close.
># note: the email is not sent until the pipe is closed.
>printf (FI "blah\nblah blah\n");
Why are you using printf() when you don't have a format specifier?
>close (FI);
jue
------------------------------
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 V11 Issue 1466
***************************************