Shutting down computer from a python script in apache
问题 I have a headless Raspberry Pi which I want to have an easy means for my child to power down. I tried the following script in the apache web server: import os sss = os.popen('echo password | sudo -S shutdown -hP now') print sss.read() But nothing happens. Then I tried: from subprocess import Popen, PIPE, STDOUT p = Popen('echo password | sudo -S shutdown -hP now', shell=True, stdOUT=PIPE, stderr=STDOUT) print p.stdout.read() Also, nothing was output and no work appears to have been done. How