Jan-26-2018, 09:21 PM
This is all running under python 3.5.2
Well after a lot more googling I have found a different approach instead of subprocess.call
I modified the code from https://pymotw.com/2/subprocess/
Can anyone suggest how I can fix this please?
Well after a lot more googling I have found a different approach instead of subprocess.call
cat = subprocess.Popen(['cat', '/home/norman/khconf/second.txt'], stdout=subprocess.PIPE, ) sort = subprocess.Popen(['sort'], stdin=cat.stdout, stdout=subprocess.PIPE, ) uniq = subprocess.Popen(['uniq'], stdin=sort.stdout, stdout=subprocess.PIPE, ) end_of_pipe = uniq.stdout lastfile = docs + "/third.txt" lastone = open(lastfile, 'w') lastone.write("Hello World") for line in end_of_pipe: lastone.write(line)I get no errors but third.txt only contains the "Hello World"
I modified the code from https://pymotw.com/2/subprocess/
Can anyone suggest how I can fix this please?