Есть скрипт веб-сервера:
import BaseHTTPServer import CGIHTTPServer port = 8080 addrport = ('', port) serv = BaseHTTPServer.HTTPServer( addrport, CGIHTTPServer.CGIHTTPRequestHandler ) serv.serve_forever() print('Server is working. Kill the PID if not needed anymore')
Есть хтмл страничка:
<html> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> <title>Interactive Page</title> </head> <body> <form method=POST action="/cgi-bin/reply.py"> <P><B>Enter your name:</B> <P><input type=text name=user> <P><input type=submit> </form> <form method=POST action="/cgi-bin/show_users.py"> <P><B>Click me, if u want all schemas</B> <P><input type=submit> </form> </body> </html>
И есть скрипт, который вызывается нажатием на нижнюю кнопку:
import os os.system('/opt/oracle/web2/cgi-bin/show_users.sh > /opt/oracle/web2/test_text.html') doc = """ <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> <title>The job is done!</title> </head> <body> Please open http://172.17.2.34:8080/test_text.html </body> </html> """ print(doc) f_out = r'<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <title>One long row</title><body><table width="100%" cellspacing="0" cellpadding="5">' with open(r'/opt/oracle/web2/test_text.html', 'r') as f: for i in f.readlines(): f_out += '<tr><td width="500" valign="top">' + i + '</td></tr>' f_out += '</table></body></html>' with open(r'/opt/oracle/web2/test_text.html', 'w') as f: f.write(f_out)
При выполнении выдается следующая ошибка:
my-ibm-w.oilspace.net - - [21/Jul/2014 10:17:22] "POST /cgi-bin/show_users.py HTTP/1.1" 200 - Traceback (most recent call last): File "/usr/lib64/python2.6/CGIHTTPServer.py", line 248, in run_cgi os.execve(scriptfile, args, os.environ) OSError: [Errno 8] Exec format error
Где я ошибся?