Solved

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

Posted on 2001-06-19
2
168 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
iSeries PERL Scripts 7 147
Perl Awk Need Help 3 109
Replace  text in a file 2 97
Using Perl DBI to query oracle 3 33
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now