How do I execute the following shell command using the Python
echo "input data" | awk -f script.awk | sort > outfile.txt
The input data will come from a string, so I don't actually need
echo. I've got this far, can anyone explain how I get it to pipe through
p_awk = subprocess.Popen(["awk","-f","script.awk"], stdin=subprocess.PIPE, stdout=file("outfile.txt", "w")) p_awk.communicate( "input data" )
UPDATE: Note that while the accepted answer below doesn't actually answer the question as asked, I believe S.Lott is right and it's better to avoid having to solve that problem in the first place!