This widget could not be displayed.
1845515 Members
2593 Online
110244 Solutions
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
This widget could not be displayed.
New Discussion
This widget could not be displayed.
This widget could not be displayed.

mailx without body

 
SOLVED
Go to solution
yc_2
Regular Advisor

mailx without body

Hi,

How to go about sending a blank mail using mailx.


Thanks in advance,
YC
11 REPLIES 11
Kofi ARTHIABAH
Honored Contributor

Re: mailx without body

Try:

mailx -s "Subject if you want" receipient
.
(that is a period on a line by itself)
I am curious, why would you want to send a mail with a null body?
nothing wrong with me that a few lines of code cannot fix!
yc_2
Regular Advisor

Re: mailx without body

Hi,

Thanks for your advise.

My pkg in MC/SG is unstable, it halted and never fail over for a few times. Instead of waiting the users to initiate the compliant, it will be good to have a simple script to monitor (ease of maintenance) the status of the pkg. Hope to get inform thro mail when it is down.

Rgds,
YC
yc_2
Regular Advisor

Re: mailx without body

Hi Kofi,

It works in the command line but not in a script. Any changes require for scripting ?


Rgds,
YC
Kofi ARTHIABAH
Honored Contributor

Re: mailx without body

Ah I see. The only thing you have to watch out for is that your network is stable and the message will get dilivered. To be absolutely sure, you could set up a dial out modem on the server and configure it to dial an alphanumeric pager with a special code when there is a problem.

Good luck.
nothing wrong with me that a few lines of code cannot fix!
Kofi ARTHIABAH
Honored Contributor

Re: mailx without body

in a script, use
echo .\n | mailx -s "test 2" arthiak

that is echo period backslash n
nothing wrong with me that a few lines of code cannot fix!
Kofi ARTHIABAH
Honored Contributor

Re: mailx without body

Sorry Leong... I just cut and paste a test case from my machine it should be:

n a script, use
echo .\n | mailx -s "subject if you want" recepient

that is echo period backslash n
nothing wrong with me that a few lines of code cannot fix!
Kofi ARTHIABAH
Honored Contributor
Solution

Re: mailx without body

Ahh... I better catch some sleep - here we are:

echo "\n" | mailx -s "subject" recepient

nothing wrong with me that a few lines of code cannot fix!
yc_2
Regular Advisor

Re: mailx without body

Hi Kofi,

It works, I really appreciate your time for solving my problem.

Would you like to advise why I can't use the exact syntax from the command line in the script ?

You were saying using a pager to get inform, I have actually think of this as well. It didn't kick off because I am no good in scripting. Would you like to share about how this can be done ?



Thanks,
YC
Kofi ARTHIABAH
Honored Contributor

Re: mailx without body

The reason it was not working the same as the command line is because mailx expects inputs from the standard input (interactive) when invoked; the echo command creates a null line which gets passed to the standard input of mailx.

Yes I have a server configured that constantly probes another one (its called from within cron every 5 minutes) I configured a script to use the cu command ( do a man on cu) I will have to post parts of the script later - its on another machine that I cannot reach right now.
nothing wrong with me that a few lines of code cannot fix!
Kofi ARTHIABAH
Honored Contributor

Re: mailx without body

Leong:

The attached script can be used to send a numeric page to a numeric pager. You can call it from another script that monitors daemons and server health etc.

Good luck
nothing wrong with me that a few lines of code cannot fix!

Re: mailx without body

Hi,

Hope following line syntax will work in script.

mailx -s "subject" receipient < /dev/null

Thanks & regards,
Jeganathan