Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

executing an external process from a servlet in Ubuntu  RSS feed

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

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

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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!