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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -