How can I get this os.system command to run "as sudo" so it works properly?
The code is below. Thanks!
Code: Select all
#!/usr/bin/env python
import cgi
import os
form = cgi.FieldStorage() # instantiate only once!
band = form.getfirst('band', 'empty')
freq = form.getfirst('freq', 'empty')
# Avoid script injection escaping the user input
band = cgi.escape(band)
freq = cgi.escape(freq)
bandLower = band.lower()
sysCommand = ("sudo /usr/local/bin/shark -"+bandLower +" " + freq)
os.system(sysCommand)
print("""\
Content-Type: text/html\n
<html><body>
<p>The submitted command was "%s"</p>
</body></html>
""" % sysCommand)