I'm running this:
os.system("/etc/init.d/apache2 restart")
It restarts the webserver, as it should, and like it would if I had run the command directly from the terminal, it outputs this:
* Restarting web server apache2 ...
waiting [ OK ]
However, I don't want it to actually output it in my app. How can I disable it? Thanks!
os.system("/etc/init.d/apache2 restart >/dev/null")will discard that output. As Noufal has said,subprocessis preferred. If you're wanting to make a quick adjustment to pre-existing code, though, redirecting to /dev/null might be an attractive option. - Kirk Strauser