[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 586
  • Last Modified:

get the return value of "mailx" command?

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
Rasasekaran
Asked:
Rasasekaran
1 Solution
 
avizitCommented:
echo $?   works in most cases
0
 
avizitCommented:
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
 
TintinCommented:
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
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
tfewsterCommented:
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
 
tfewsterCommented:
Oops, my comment was in response to avizits - Tintin has covered it
0
 
ahoffmannCommented:
# sh and friends:
echo $?
# csh and friends:
echo $status
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now