How to send "mail", with no body, from within a UNIX script

  • Follow


I created a script to monitor the number of sessions in an Oracle
database. When the number of sessions exceeds a threshold I use a UNIX
"mail" command to send an email message, and an electronic page.
Everything to need to know is contained in the subject line. I have no
need to send text in the body of the message. The only way I have
found to make the command work without errors is to load the body with
a file that contains a single space. I tried "</dev/null" but that did
not work. Does anyone have a suggestion on how I can use "mail"
without putting anything in the body?

I know the code below works, but I do not want to employ the empty
file, "admtest_session_empty_file.lst".

#Send a message if the session count is high.
if [ $count_sessions -gt 60 ]
then
    mail -s "INSTANCE sessions high: $count_sessions"
xxxxxxx@xxxxx.com yyyyyy@yyypage.yyyy.com zzzzzzz@zzzzz.com
<admtest_session_empty_file.lst
fi

Thank you,
Bill
0
Reply bfog 1/20/2010 4:50:10 PM

bfog wrote:
> I created a script to monitor the number of sessions in an Oracle
> database. When the number of sessions exceeds a threshold I use a UNIX
> "mail" command to send an email message, and an electronic page.
> Everything to need to know is contained in the subject line. I have no
> need to send text in the body of the message. The only way I have
> found to make the command work without errors is to load the body with
> a file that contains a single space. I tried "</dev/null" but that did
> not work. Does anyone have a suggestion on how I can use "mail"
> without putting anything in the body?
> 
> I know the code below works, but I do not want to employ the empty
> file, "admtest_session_empty_file.lst".
> 
> #Send a message if the session count is high.
> if [ $count_sessions -gt 60 ]
> then
>     mail -s "INSTANCE sessions high: $count_sessions"
> xxxxxxx@xxxxx.com yyyyyy@yyypage.yyyy.com zzzzzzz@zzzzz.com
> <admtest_session_empty_file.lst
> fi
> 
> Thank you,
> Bill

Hi Bill,

My first reaction would be to use\
   echo | mail -s ...
which should send an e-mail with just an empty line as body. You could 
alse experiment with "echo -n" and see how mail reacts.

Regards,
Alvin.
0
Reply Alvin 1/20/2010 7:05:54 PM


On Jan 21, 5:50=A0am, bfog <bfoga...@gaports.com> wrote:
> I created a script to monitor the number of sessions in an Oracle
> database. When the number of sessions exceeds a threshold I use a UNIX
> "mail" command to send an email message, and an electronic page.
> Everything to need to know is contained in the subject line. I have no
> need to send text in the body of the message. The only way I have
> found to make the command work without errors is to load the body with
> a file that contains a single space. I tried "</dev/null" but that did
> not work. Does anyone have a suggestion on how I can use "mail"
> without putting anything in the body?
>
> I know the code below works, but I do not want to employ the empty
> file, "admtest_session_empty_file.lst".
>
> #Send a message if the session count is high.
> if [ $count_sessions -gt 60 ]
> then
> =A0 =A0 mail -s "INSTANCE sessions high: $count_sessions"
> xxxx...@xxxxx.com yyy...@yyypage.yyyy.com zzzz...@zzzzz.com
> <admtest_session_empty_file.lst
> fi
>
> Thank you,
> Bill

use Nagios - it's free :)
0
Reply Henry 1/20/2010 7:15:50 PM

Hello Bill.

Try this:

$ true | mail -s "no body just subject" wisnios@gmail.com
Null message body; hope that's ok

Kind regards.
Marcin
0
Reply wisnios 1/20/2010 10:28:35 PM

On Jan 20, 11:50=A0am, bfog <bfoga...@gaports.com> wrote:
> I created a script to monitor the number of sessions in an Oracle
> database. When the number of sessions exceeds a threshold I use a UNIX
> "mail" command to send an email message, and an electronic page.
> Everything to need to know is contained in the subject line. I have no
> need to send text in the body of the message. The only way I have
> found to make the command work without errors is to load the body with
> a file that contains a single space. I tried "</dev/null" but that did
> not work. Does anyone have a suggestion on how I can use "mail"
> without putting anything in the body?
>
> I know the code below works, but I do not want to employ the empty
> file, "admtest_session_empty_file.lst".
>
> #Send a message if the session count is high.
> if [ $count_sessions -gt 60 ]
> then
> =A0 =A0 mail -s "INSTANCE sessions high: $count_sessions"
> xxxx...@xxxxx.com yyy...@yyypage.yyyy.com zzzz...@zzzzz.com
> <admtest_session_empty_file.lst
> fi
>
> Thank you,
> Bill


Thank you Alvin, Henry, and Marcin.

I tried both echo and true. What worked for me was:
echo|mail =96s =93message text=94 xxxx...@xxxxx.com yyy...@yyypage.yyyy.com
zzzz...@zzzzz.com

The message created with:
true|mail =96s =93message text=94 xxxx...@xxxxx.com yyy...@yyypage.yyyy.com
zzzz...@zzzzz.com
produced an email that look good, but the electronic page included the
following message body:
=93<html><body></body></html>=94
That matched the results produced by using the mail command alone, and
omitting any reference to the body.

Thank you all for your suggestions.
Bill

0
Reply bfog 1/21/2010 3:24:47 PM

4 Replies
569 Views

(page loaded in 0.045 seconds)

Similiar Articles:













7/23/2012 6:51:40 PM


Reply: