bash - I am trying to send mail in python using shell command . But variable does not get substituted in script -


import subprocess ='xxxx@fmr.com' subject= 'hostname' cmd= "cat /var/log | mailx -s 'swap full on'+subject" +to subprocess.popen(cmd,shell=true) 

if place double quote before subject mailx takes first character subject , treat other recipient , try send mail them .

--------------------out put of cmd= "cat /var/log | mailx -s 'swap full on'"+subject +to

can try this:

import subprocess ='xxxx@fmr.com' cmd= "cat /var/log | mailx -s 'test' " + subprocess.popen(cmd,shell=true) 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -