I am trying to send mail in python using shell command . But variable does not get substituted in script
<pre><code>import subprocess
to ='xxxx@fmr.com'
subject= 'hostname'
cmd= &quot;cat /var/log | mailx -s 'swap is full on'+subject&quot; +to
subprocess.Popen(cmd,shell=True)
</code></pre>
<h1>if i place double quote before subject then mailx takes first character as subject and treat other as the recipient and try to send mail to them .</h1>
<h1>--------------------out put of   cmd= &quot;cat /var/log | mailx -s 'swap is full on'&quot;+subject +to</h1>