seaver has asked for the wisdom of the Perl Monks concerning the following question:
I have created a web interface that runs a perl script once the form has been submitted. The server is tomcat and the webpages are JSP.
I have written a little line in the beginning of the perl script that 'touches' a new file to indicate that it is running. Whilst running it, it puts its results into a previously created and unique directory.
This results are then in turn accessed again by the web interface.
Everything goes well except for one weird thing, when I want to run the script again, ie re-submit the form WITHIN the same session. The 'touched' file that indicates that the perl script was started is updated, so I KNOW that the perl script started to run. But there is NO OTHER output, and the script itself crashes or exits before I even can find it with 'ps ax'.
I am confused as to why it does this after the first time it is run. if I close the browser completely, and wait 60 minutes, then it will work again just fine.
I really believe it's something to do with the output streams:
in the bean that runs the script I have this java code:open SAVEERR, ">&STDERR"; open SAVEOUT, ">&STDOUT"; $|=1; ...rest of script... close STDERR; open STDERR, ">&main::SAVEERR"; close STDOUT; open STDOUT, ">&main::SAVEOUT";
String[] cmd ={"/home/seaver/MONSTER/monster", "-i" + jobID, filePath ++ pdbFileName}; try{ Process proc = Runtime.getRuntime().exec(cmd); BufferedWriter output = new BufferedWriter(new OutputStrea +mWriter(proc.getOutputStream())); BufferedReader input = new BufferedReader(new InputStreamR +eader(proc.getInputStream())); BufferedReader error = new BufferedReader(new InputStreamR +eader(proc.getErrorStream())); output.close(); input.close(); error.close(); }catch (Throwable t){ t.printStackTrace(); }
can anyone throw any light on this?
thanks Sam
edit jeffa - s/pre/code/g
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl script ran from Java Bean
by perlplexer (Hermit) on Apr 17, 2003 at 20:31 UTC |