Running the following python script through web site works fine and (as expected) stops the playback of MPD:
#!/usr/bin/env python
import subprocess
subprocess.call(["mpc", "stop"])
print ("Content-type: text/plain;charset=utf-8\n\n")
print("Hello")
This script however causes an error (playback starts as expected):
#!/usr/bin/env python
print("Content-type: text/plain;charset=utf-8\n\n")
print ("Hello")
import subprocess
subprocess.call(["mpc", "play"])
The error is:
malformed header from script. Bad header=Scorpions - Eye of the tiger -: play.py, referer: http://...
Apparently whatever is returned by the playback command is taken as the header. When run in terminal, the output looks fine. Why could it be?