I am currently writing a CGI script that has an end goal of running a Java program and then on a separate page Being redirected. However, when I try to run the Java program, CGI 500 internal server error causes I have tried OSSystem ("[Command"]) and call (["command"]) and subprocess. Popen ("command") and all three are asked to crop the same issue.
Edit In addition to this, Apache log does not tell me any information only by saying that there is an invalid header. Edit Not the whole command, but I believe it's done correctly Has been received because I can copy the printed command and run it in the terminal and it runs completely. This command is only Java [class name] [9 args] Java code of Python code Runs out smoothly and creates all this .png file and .html file with PNG.The file name is [user_id] .html, therefore the redirect. In the internal server error No , if only process command The comment is made. Edit has ended and went to php to execute this script. Thanks for all the help! If Your Java The command probably sys.stdout and or sys.stderr if so, this output goes to Apache. Ideally, some stuff has already gone to Apache, which is a proper title through sys.stdout and everything Okay. However, the way things get buffer Minister, there is a small chance that had no useful response to Apache and confuse Java output. I suggest that you switch to I also suggest that you capture the subproduction output in a file and then copy it, the file can not be confused with the Java subprocess in Apache in sys.stdout.
#! / Usr / bin / python # import cgi module import cgi import random import os import system import re-import subprocess # essential header which tells the browser html render print "content-type: text / html \ n \ n" form = Cgi.FieldStorage () userID = random.random () print "& lt; html & gt;" Print "& lt; Title & gt; Results & lt; / title & gt;" Print "& lt; body & gt;" Command = "java [classname]" user_id = random.randint (0, sys.maxint) command + = str (user_id) + command + = redo Value + command = = ['key3']. Value + "value +" "If form.has_key ('key3') and" 0 "## is the problem where the problem is # os.system (" ls -l ") #call ([" ls "," -l "]) #p = subprocess .popen (command) # # Print the print command of the problem "& lt; br & gt;" print "redirection ..." print "& lt; meta http-equiv = 'refresh' content = '0; url =" , Print "http://192.168.1.41/Path/", print user_id, print ".html '/ & gt;" print "& lt; / body & gt;" print "& lt; / html & gt;
## This is where the problem is #OsSystem ("LS-L") #call (["ls", "-l"] #p = subprocess. Popin (command) ## end of problem
focus on subprocesses POPIN . All others are left permanently. They are all bad thoughts
subprocess.Popen (command) actually In the form of a single small Python script, you have to test Apache or not to run this CGI-bin Remember that the username has the necessary privileges. Apache does not run as you run it with different privileges as a separate "person".
mod_wsgi rather than CGI because it is easy to control.
Comments
Post a Comment