Re: can't run mailx as PERL system command



From: Elliot Holden <eh@xxxxxxxxxxxxxxxx>
ok this is problem going to be real easy for one of you PERL gurus but

It's either Perl (the language) or perl (the interpreter), there is
no such thing as PERL.

my little brain just can't figure it out. From the command line (Solaris
9) I can do this fine:

echo my little test | mailx -s "Test Message" email@xxxxxxxxxxxx

But in PERL the below code does not work:

system("echo my little test | mailx -s \"Test Message\"
email@xxxxxxxxxxxx");

Use one of the many modules available from CPAN for sending email.
MIME::Lite, Mail::Sender, Mail::Mailer, Mail::Sendmail, ... to name
just a few. It's possible that some of them are already installed.

even if I just do:

system("mailx email@xxxxxxxxxxxx");

If you

use strict;

you get an error that will make it clear that perl though you want to
insert the contents of array @mydomain into the doublequoted string.
You have to escape $ and @ in doublequoted strings, otherwise you do
not get theliteral $ or @ but the contents of some variable. Or an
error if you use strict and the variable was not declared.

HTH, Jenda
===== Jenda@xxxxxxxxxxx === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery

.



Relevant Pages

  • Re: return code
    ... > echo yes command succeeded ... > In Perl if I wanted to represent this I would use $! ... > use strict 'subs'; ...
    (perl.beginners)
  • Re: return code
    ... Perl 0 = false ... SHELL 1 = false ... > echo yes command succeeded ... > use strict 'subs'; ...
    (perl.beginners)
  • Re: When to "use strict" when teaching?
    ... >>being influenced by the history of Perl ... history bias you" essentially the same as saying you are not ... An understanding of how symbolic references work is neither necessary ... I say don't expose people to the idea of omitting "use strict" until ...
    (comp.lang.perl.misc)
  • RE: I need help here
    ... Here's the Big Secret about Perl variables that most people learn ... use strict; ... : $outputfile = shift; ... You will often see a usage message in a script which deals ...
    (perl.beginners)
  • Re: Perl Peeves
    ... the context is known at compile time. ... use strict; ... well-defined in Perl. ... number/string ambivalence of scalars. ...
    (comp.lang.perl.misc)