Solved

get the return value of "mailx" command?

Posted on 2004-09-09
6
552 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
Error on moodle after upgrade 3 140
Is there a simple front-end menu system. 9 102
Problem to App 4 97
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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