Forums Register Login

executing an external process from a servlet in Ubuntu

+Pie Number of slices to send: Send
I have been banging my head on the table for a while over this problem (I am very new to linux). I am trying to invoke a simple python script from a servlet running in Tomcat6 on Ubuntu 10.04. I have been able to get it to run in a simple java program as follows:

try{
String[] cmd ={"python", "/home/troy/NetBeansProjects/GSMFilter/web/WEB-INF/storage/helloWorld.py", "-c"};
ProcessBuilder pb = new ProcessBuilder(cmd);
Process p = pb.start();
}
catch(Throwable t){
t.printStackTrace();;
}

My servlet takes information entered in a jsp form and writes it to two text files and then is suppose to call a python script. As as I said above, the call to the python script works fine in a simple java file on Ubuntu, however, when I try the same thing in a servlet, everything in the servlet executes (writes to files and forwards it to the proper confirmation jsp) with the exception of the python script. The frustrating thing is that when I run the same program on windows (with the proper arguments for windows) the script executes from the servlet. I have given all the permissions I can find in Tomcat policies files and have made sure the permissions on the python are executable by all users. I have used proc.waitFor() and get an exit value of 0. I have read the article at javaworld When Runtime.exec() won't about a dozen time and compiled the classes suggested without much luck (read "no change"). There is no error to report, I catch that in my servlet and ship the user over to an error page, but I get the confirmation page saying all has worked as it should. Obviously, I would appreciate any help anyone could offer.

By the way, I have used your site many times and really appreciate what you offer.
I don't get it. A whale wearing overalls? How does that even work? It's like a tiny ad wearing overalls.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1385 times.
Similar Threads
Using Processbuilder and telnet
call java (main) program from JSP
Catching InputStream from Runtime/Process
Issues Compiling With Javac
problem with Runtime.getRuntime().exec when running java in .bat
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:52:10.