Operating System - HP-UX
1752799 Members
5781 Online
108789 Solutions
New Discussion юеВ

Re: Empty subject when using mailx.

 
SOLVED
Go to solution
Adnane_1
Occasional Advisor

Empty subject when using mailx.

Hello Folks,
I getting an empty email when using the following command in a Korn shell script:

subject="Testing ..."
echo "Subject =${subject}"
mailx -s"${subject}" myemail
Anyone can help on this?

Adnane
17 REPLIES 17
James R. Ferguson
Acclaimed Contributor

Re: Empty subject when using mailx.

Hi Adnane:

By redirecting /dev/null to STDIN you got exactly what you asked: an empty email body.

You could redirect another file, instead, or you could type your email body message at the command line and type CNTL_D (end-of-text) to signal its end. For example:

mailx -s "Testing..." myuser
This is line-1
and this is line-2
of a three-line message


Regards!

...JRF...
Muthukumar_5
Honored Contributor

Re: Empty subject when using mailx.

Try with this,

subject="Testing..."
echo "Subject= ${subject}"

mailx -s "$subject" root@localhost mail

You will get that recent mail with Testing... as subject.

hth.
Easy to suggest when don't know about the problem!
Adnane_1
Occasional Advisor

Re: Empty subject when using mailx.

Guys,
I getting an empty subject. The /dev/null is intentional to get an empty email but why the subject is empty?


Thanks.
Muthukumar_5
Honored Contributor

Re: Empty subject when using mailx.

What you are getting with sendmail?

# subject="check..."
# echo "Subject: ${subject}" | sendmail root@localhost
# mail

hth.
Easy to suggest when don't know about the problem!
Pat Lieberg
Valued Contributor

Re: Empty subject when using mailx.

Take out the () in your mailx line. It should read:

mailx -s "$subject" myemail
Gavin Clarke
Trusted Contributor

Re: Empty subject when using mailx.

There seems to be a space missing between the -s and the "${subject}".

I also get the feeling that Pat is right and the {} need to go too.
Matthew_50
Valued Contributor

Re: Empty subject when using mailx.

Hi, Adnane,

I think the second line is not necessary, simply use

#!/bin/ksh
subject="Testing ..."
mailx -s ${subject} who@myemail.com < /dev/null
Adnane_1
Occasional Advisor

Re: Empty subject when using mailx.

Hi Folks,
I tried your suggestions and I├в m getting the same problem (the sendmail as mention by HTH did not work for me, I think the setup for the DS entry is messing in the sendmail.cf file).
However I found out that when I submit the job my self I got the the email and the subject but when the scripts is submitted by the scheduler MAESTRO (scheduler program from IBM that runs under UNIX HP) I got the email but not the subject.

Did anyone have an idea ?



Thanks to all for your help.
Pat Lieberg
Valued Contributor

Re: Empty subject when using mailx.

It sounds to me like the $subject is not being interpretted by the script and might be interpretted by the shell, which is evaluating to nothing and therefore, no subject.

As mentioned in Matthew's post, do you have the #!/bin/ksh line at the top of your script?