I was playing around with Python's subprocess module, trying a few examples but I can't seem to get heredoc statements to work.
Here is the trivial example I was playing with:
import subprocess
a = "A String of Text"
p = subprocess.Popen(["cat", "<<DATA\n" + a + "\nDATA"])
I get the following error when I run the code above:
cat: <<DATA\nA String of Text\nDATA: No such file or directory
Am I doing it wrong? Is this even possible? If so how would I go about doing it?
Update
Just wanted to say that this should never be performed in a real python program because there are better ways of doing this.