Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Program hang when using Runtime.exec() unders Linux platform

Posted on 2004-04-19
3
Medium Priority
?
349 Views
Last Modified: 2013-11-08
Hello,

I tried to execute a FORTRAN program by using Runtime.exec() under Linux platform. I am using Java Tomcat 1.4.1.29.
However, the FORTRAN application hang forever, which usally takes about 2 minutes to finish.

I have no problem to run it under console based stand alone application.

The codes is as follows:

                /* make a shell script*/
                BufferedWriter bw2=new BufferedWriter(new FileWriter(currentDir+"/pentran.script"));
                bw2.write("#!/bin/sh"+ "\n");
                bw2.write("cd "+currentDir+"/"+"\n");
                bw2.write("echo sample.f90 "+" | "+" /opt/tomcat/pentran/pentran" );
                bw2.close();

               /*create a process*/
                Runtime rt = Runtime.getRuntime();
               
               /*chmod permission*/
                Process changeMode = rt.exec( "chmod 755 " + currentDir + "/pentran.script" );

                Process pr = rt.exec(currentDir+"/pentran.script");

Does anyone have any ideas?

Best Regards,
Peng
0
Comment
Question by:penglu
3 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 10868001
I know very little in this area, but can I suggest you try this

put diagnostics between each main area, so you can identify where exactly the delay is, then tackle that


// DIAG1 - DISPLAY "About to create Buffer" and also show  date/time
               /* make a shell script*/
                BufferedWriter bw2=new BufferedWriter(new FileWriter(currentDir+"/pentran.script"));

// DIAG2 - DISPLAY "About to create file" and also show  date/time

                bw2.write("#!/bin/sh"+ "\n");
                bw2.write("cd "+currentDir+"/"+"\n");
                bw2.write("echo sample.f90 "+" | "+" /opt/tomcat/pentran/pentran" );
                bw2.close();

// DIAG3 - DISPLAY "About to create process" and also show  date/time
               /*create a process*/
                Runtime rt = Runtime.getRuntime();
               
// DIAG4 - DISPLAY "About to change perms of script" and also show  date/time
               /*chmod permission*/
                Process changeMode = rt.exec( "chmod 755 " + currentDir + "/pentran.script" );

// DIAG5 - DISPLAY "About to run script" and also show  date/time

                Process pr = rt.exec(currentDir+"/pentran.script");

// DIAG6 - DISPLAY "end" and also show  date/time
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Introduction to Processes

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question