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
Post a Comment