'echo -e' + subprocess
Verfasst: Montag 21. März 2016, 11:18
Hallo zusammen.
Ich möchte ein Shell Kommando mit subprocess ausführen. Dabei möchte ich Zeilenumbrüche im Text haben. Das geht mit 'echo -e'. Nur leider funktioniert das nicht wenn ich es im subprocess mache. Was mache ich da falsch?
HeAdLeSs
Ich möchte ein Shell Kommando mit subprocess ausführen. Dabei möchte ich Zeilenumbrüche im Text haben. Das geht mit 'echo -e'. Nur leider funktioniert das nicht wenn ich es im subprocess mache. Was mache ich da falsch?
Vielen Dank.import subprocess
text = "Hallo\nhier ein Test\n\nText."
inputcommand = 'echo -e "%s" | gammu-smsd-inject TEXT %s' % (text, number) #speak aloud
p = subprocess.Popen(inputcommand, stdout=subprocess.PIPE, shell=True)
HeAdLeSs