I have the following shell script fragment.var_name='ZZPCI'for emailadd in `cat /tmp/email_list.tmp`do   subject_text=Subject with Var Name $var_name   subj_text_novar=Subject without Var Name   email_mssge=this is the message with variable name $var_name   echo $email_mssge|mailx -a /tmp/my_report.txt -s $subject_text $emailadd   echo $email_mssge|mailx -a /tmp/my_report.txt -s $subj_text_novar $emailadddoneWhat it does is a. Sets the variable var_nameb. Reads through the list of email addresses stored in /tmp/email_list.tmpc. Compiles and sends an email with /tmp/my_report.txt (plain text file) as an attachmentThe script is intended to run on a number of different servers, so var_name will change with each server.The mail command with $subj_text_novar, (does not include $var_name in the subject string), sends the email correctly .However the mail command with $subject_text which does include $var_name places the contents of the attachment into the main body of the email.As far as I can make out, it is the actual $-sign causing the problem because hardcoding the var_name value into the string is fine but I don't see why because surely var_name is just a concatenated stringSo, how can I set the subject for mail so it includes $var_name and my text file is sent as an attachment?I am running this on SuSE 11.3 but the solution ideally needs to work on AIX 6.1 and HP UX11.31 as wellRegards
How to set mail subject using variable and ensure attachment is not included in email body
linux;email;solaris;aix;mailx