I’ve inherited legacy Perl CGI scripts that used to be able to receive information from an HTML form (via POST) and compile some java source files with that form data (ultimately creating a Java applet). They do not compile any more, and I need to figure out why.
The most obvious issue (though I don’t know what changed to make it go from working to not) is that the CGI script cannot find the java compiler (sh: /usr/bin/javac: No such file or directory) it is called by a submitted HTML form.
I inserted a call into the CGI script to compile a simple java file (/usr/bin/javac ./HelloWorld.java) that precisely mimics the call to the big java file (which requires parameters to be set from the POST data) that fails. So my hope is that if I can get the submission of the HTML form to compile my HelloWorld file, it would also be able to compile the big files that require parameters.
When I call the CGI script from the command line, the java compiler is found and it compiles my HelloWorld java file, but when I use the HTML form, java is not found (even /usr/bin/java -version does nothing). The placement of my compile statement within the CGI script doesn’t matter (so it’s not a matter of where the compile statement is in relation to my handling of the HTTP request), it always compiles with when called by the command line and fails to find java when called by the form.
Is there a reason that java would not be visible to the CGI script when called by a form (POST) but would be visible when called by the command line?
Thanks in advance!
Bernie
The environment around Apache and CGI is not the same as an interactive console.
You may try to write a basic Bourne shell script (sh) with ALL the path specified.
Compiling Java on-the-fly from a form is really needed?
I’m curious: why?