If I type the following command into the terminal, it works and a message "test" is sent.
sudo echo "test" | sendxmpp -t -u doorbellding -o gmail.com in06khattab I wanted to execute this command in Python, but instead of test it would a variable containing the data and time
This is what I have tried, but they all fail.
message="Ding Dong at "+strftime("%l:%M %p on %d-%m-%Y") os.system('sudo echo '+message+' | sendxmpp -t -u doorbellding -o gmail.com in06khattab') #send hangouts message os.system('sudo echo "test" | sendxmpp -t -u doorbellding -o gmail.com in06khattab') 

echo; just run thesendxmppcommand withsubprocess.Popen, withstdin=subprocess.PIPE, and you can feed it the data directly.communicate, etc. Take the time to learnsubprocessproperly; yes it's more work up front, but it's safer, more stable, and more powerful.