Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am stuck with an issue regarding the failure of Runtime.getRuntime().exec(String) that creates a new process in our application. Though this code worked successfully on the sun system (java 1.4, tomcat 4.0) it does not seem to work at all on Linux. The configurations on linux system are

  • Linux: Fedora 10, Java version: 1.6, Tomcat version: 5.5

Here is the code snippet that runs TestProcess class as a new process:

    process = Runtime.getRuntime().
               exec (new String[] {"/bin/sh","-c",
                 "java OcwCommon.OcwProcessController" + " " +action+ " " +Id);

The ‘process’ variable does not return a null. And no logs are created for the new process. Hence we assume that it is not getting executed.

i am running tomcat with fsuser and i have added classpath, path etc env variables in /etc/profile file. So it gets loaded whenever system boots.

Can there be any authorization issue in creating a new process? Though we have double checked it.

Any pointers would be much appreciated.

share|improve this question
    
what happens when you run the command directly in a prompt? –  Leonel Martins Jul 24 '09 at 18:34

2 Answers 2

Query updated

I am stuck with an issue regarding the failure of Runtime.getRuntime().exec(String) that creates a new process in our application. Though this code worked successfully on the sun system (java 1.4, tomcat 4.0) it does not seem to work at all on Linux. The configurations on linux system are

  • Linux: Fedora 10, Java version: 1.6, Tomcat version: 5.5

Here is the code snippet that runs TestProcess class as a new process:

process = Runtime.getRuntime().exec (new String[] {"/bin/sh","-c"
                "java OcwCommon.OcwProcessController" + " " +action+ " " +Id);

The ‘process’ variable does not return a null. And no logs are created for the new process. Hence we assume that it is not getting executed.

i am running tomcat with fsuser and i have added classpath, path etc env variables in /etc/profile file. So it gets loaded whenever system boots.

Can there be any authorization issue in creating a new process? Though we have double checked it.

Any pointers would be much appreciated.

share|improve this answer
    
you should edit the post and not add a answer. –  Leonel Martins Jul 24 '09 at 18:32

Why are you running it twice? I think the line should be as follows

String[] cmd = "/bin/sh","-c", "java OcwCommon.OcwProcessController" + " " +action+ " " +Id;

process = Runtime.getRuntime().exec(cmd);

Stuart

share|improve this answer
    
my bad, read it as process = Runtime.getRuntime(). exec (new String[] {"/bin/sh","-c" "java OcwCommon.OcwProcessController" + " " +action+ " " +Id); The query still stands.. –  harshildesai Jul 24 '09 at 17:00
    
the only thing I can see is the missing + between " -c" and " java –  stuart Brand Jul 24 '09 at 19:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.