Solved

get the return value of "mailx" command?

Posted on 2004-09-09
6
551 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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…
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.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

813 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

16 Experts available now in Live!

Get 1:1 Help Now