Solved

get return value of open(MAIL,"|mail.pl)

Posted on 2001-06-19
2
200 Views
Last Modified: 2010-03-05
I use my self-written perl-script to send mail.
It returns an exit code of 1 if an error has occured! But how to get the error code?
I use it like:

open(MAIL, "|mail.pl");
print MAIL "From: \"xx\@xx.com\" <xx\@xx.com>\n".
           "To: \"xx\@xx.com\" <xx\@xx.com>\n".
           "Subject: TEST\n\n".
           "This is the body";
close(MAIL);

but how do I get the error code???

thanks
witty
0
Comment
Question by:witty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 6206927
close(MAIL) or warn $! ? "Error closing MAIL: $!" : "exit status $?";
0
 
LVL 5

Accepted Solution

by:
Sapa earned 50 total points
ID: 6206948
"but how do I get the error code???"

It is in the $? variable after close(MAIL) is done.
Add:

print "Return code: ",($? >> 8),"\n";

The least 8 bits of $? contains information about signal
number if child process was killed.

- Sapa
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question