Solved

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

Posted on 2004-04-19
3
343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

636 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