Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2004-04-19
3
Medium Priority
?
347 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 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

660 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