General

How to send mail using mailx with just subject and no body of message

 
SOLVED
Go to solution
Sammy_2
Super Advisor

How to send mail using mailx with just subject and no body of message

Trying to send mail with just the subject to root@abc.com using mailx.
/usr/bin/mailx -s "`uname -n` Problem running ioscan status=$?" root@abc.com
But it hangs and expect me to enter body of message?
How do you fix it from within the script(so that I can use mailx or sendmail ) I just wanna send the subject and no body of the message. Please see simple script below.

=============cut here====================
#!/usr/bin/ksh
/usr/sbin/ioscan
if [ $? -eq 0 ];then
echo "It worked"
else
echo "Does not work"
mailx -s "`uname -n` Problem running ioscan status=$?" root@abc.com
fi
================cut here===================


good judgement comes from experience and experience comes from bad judgement.
4 REPLIES 4
S.K. Chan
Honored Contributor
Solution

Re: How to send mail using mailx with just subject and no body of message

Do this instead ..
mailx -s "`uname -n` Problem running ioscan status=$?" root@abc.com < /dev/null

John Poff
Honored Contributor

Re: How to send mail using mailx with just subject and no body of message

Hi,

I just tried this (on an 11.00 box) and it worked:

mailx -s "Test e-mail with no body" myemail

JP
Kellogg Unix Team
Trusted Contributor

Re: How to send mail using mailx with just subject and no body of message

Try this -

mailx -s "Subject" root@abc.com < /dev/null

...Manjeet
work is fun ! (my manager is standing behind me!!)
Sammy_2
Super Advisor

Re: How to send mail using mailx with just subject and no body of message

Thanks to S.K.Chan, Kellogg and John. Worked fine. Appreciate it.
good judgement comes from experience and experience comes from bad judgement.