Solved

get the return value of "mailx" command?

Posted on 2004-09-09
6
564 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
[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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

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 21

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 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