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' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -