Solved

get the return value of "mailx" command?

Posted on 2004-09-09
6
546 Views
Last Modified: 2013-12-26
Hi,

I am using "mailx" command in unix.
How do I get the return value of this command to know that whether this command is successful or not?

Thanks

Rasa.
0
Comment
Question by:Rasasekaran
6 Comments
 
LVL 11

Accepted Solution

by:
avizit earned 50 total points
ID: 12016994
echo $?   works in most cases
0
 
LVL 11

Expert Comment

by:avizit
ID: 12017094
but seems it doesnt work in case of "mailx"

cos the command doesnt fail until it had actually gone to the destinaton and then it finds that the destination domain has no such user as xyz etc ...

0
 
LVL 48

Expert Comment

by:Tintin
ID: 12021385
Depends on the definition of "successful" or not.

Doing

mailx -?

will cause it to "fail" and return a status of 1.  Or to script it:

mailx <options> || echo "mailx failed with a status of $?"

However, if Rasasekaran was meaning whether the mail was successfully delivered or not, then it is not possible to reliably determine this.
0
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.

 
LVL 20

Expert Comment

by:tfewster
ID: 12021470
In which case, mailx hasn't errored - and neither has sendmail, which actually does the sending & receiving ;-)

Rasa, are you looking for something like a delivery receipt?
0
 
LVL 20

Expert Comment

by:tfewster
ID: 12021475
Oops, my comment was in response to avizits - Tintin has covered it
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 12024056
# sh and friends:
echo $?
# csh and friends:
echo $status
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
Rewrite URL With Encoded Characters 6 74
Creating Labels and Frequency list style reports in SAS code 9 92
maxBlock challenge 30 111
sumHeights  challenge 17 65
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

939 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

9 Experts available now in Live!

Get 1:1 Help Now