Dear all,

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:

open SAVEERR, ">&STDERR"; open SAVEOUT, ">&STDOUT"; $|=1; ...rest of script... close STDERR; open STDERR, ">&main::SAVEERR"; close STDOUT; open STDOUT, ">&main::SAVEOUT";
in the bean that runs the script I have this java code:
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


In reply to Perl script ran from Java Bean by seaver

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.