On Tue, 26 Jun 2001, KEVIN ZEMBOWER wrote:
> I need some help using the perl command "system" to invoke sendmail. I'm trying to
>send an
> email message to a mailing list. I got what I'm trying to do from a shell script:
>
> /usr/sbin/sendmail [EMAIL PROTECTED] <<HERE
> To: [EMAIL PROTECTED]
> X-Command: $maintainer $password $command
> Subject: X-Processed: $command of <[EMAIL PROTECTED] >
>
>
> HERE
>
> I'm trying to duplicate what this section of the shell script does in perl.
>
> I've tried this, but it doesn't work:
> print ("sendmail error is ", system ('/usr/sbin/sendmail kzembower\@jhuccp.org \
> To: kzembower\@jhuccp.org\n\
> X-Command: test\n\
> Subject: X-Processed: test\n\
> \n\
> \n\
> .'));
Actually, the way to do it in Perl is very similar to what you are doing
in your shell script. The big difference is that you open up a pipe to
sendmail as a filehandle:
open(MAIL, "| /usr/sbin/sendmail -oi -t -odq") or die "Can't open
sendmail: $!\n";
print MAIL <<"HERE";
To: [EMAIL PROTECTED]
X-Command: $maintainer $password $command
Subject: X-Processed: $command of <[EMAIL PROTECTED] >
HERE
-- Brett
http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
Truly simple systems... require infinite testing.
-- Norman Augustine