I have script that seems to have stopped working after my latest upgrade. To find the problem, I wrote a little script:
import subprocess
hdparm = subprocess.Popen(["xargs","echo"],
stdin=subprocess.PIPE)
hdparm.stdin.write("Hello\n")
hdparm.stdin.write("\n")
hdparm.stdin.close()
hdparm.wait()
quit()
This just prints "Hello" and a new line, but I expect two newlines. What's causing this? (I am using 2.7.3 at the moment)
EDIT: Here is the problematic script (edited for clarity):
hdparm = subprocess.Popen(["hdparm", "--please-destroy-my-drive", "--trim-sector-ranges-stdin", "/dev/sda"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
hdparm_counter = 0
for rng in ranges_to_trim:
hdparm.stdin.write("%d:%d\n" % (rng["begin"],rng["length"]))
hdparm_counter += 1
if hdparm_counter > 63:
hdparm.stdin.write("\n")
hdparm_counter = 0
if hdparm_counter != 0:
hdparm.stdin.write("\n")
hdparm.stdin.close()
hdparm.wait()
EDIT: I believe the problem is with my script itself. I need to send EOF to hdparm to make it do whatever it is supposed to.