die, was (Re: CGI email)

mike at heckman.net mike at heckman.net
Sat Feb 26 13:36:56 CST 2000

On Sat, 26 Feb 2000 02:10:20 -0800 (PST), C. Abney wrote:

>On Fri, 25 Feb 2000, Sander van Zoest wrote:
>> On Fri, 25 Feb 2000, C. Abney wrote:
>> > wtf???  Where the heck is die printing, anyway?  And why doesn't this
>> > work like (I think) it should?:
>> any Carp() will be output to STDERR which in the case of a cgi script the
>> error log. Any STDOUT by default would go to the web client, although
>> this might not always be the case (mod_perl might not, unless you
>> are using Apache::Registry () )
>Well, I was trying to capture the error output and bend it to my will,
>as it were.  But I don't get my 'die' text in the foo.err.txt of that
>little code snippet I provided:
>	# this makes it into the (STDERR redirect) error file
>		unless ( -x "/usr/LIB/sendmail" );
>	# this doesn't. I get the bog standard error
>	# but only with warnings on.
>	open SENDMAIL, "| /usr/LIB/sendmail -t"
>		or die "AAAUUUUUGGGGHHHHH!!!: $!\n";
>I assumed die would send it's argument (string) to STDERR.  This doesn't
>seem to happen when making a system call.  Do I need to trap something?

The problem is that on opens that contain a pipe, the return value is
the process id of the spawned shell.  Therefore, testing the value of
the open directly will always return true.  What you need to do is
check the status of the child return value after you've closed the
piped open.  The code should look something  like:

open (SENDMAIL, "|/usr/LIB/sendmail -t");
print SENDMAIL "To: test\@testing.tst\nSubject: Hi!\n\nText Body";
if ($?) { die "Error sending mail"; }

Hope this helps,

perl -e 'print map{chr($x+=$_)}(74,43,-2,1,-84,33,45,1,5,-12,-3,13,-82,48,21,13\

The posting address is: san-diego-pm-list at hfb.pm.org

List requests should be sent to: majordomo at hfb.pm.org

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at happyfunball.pm.org> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at happyfunball.pm.org> .
This is the general rule for most mailing lists when you need
to contact a human.

More information about the San-Diego-pm mailing list