Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to run external perl script through jsp

843829Nov 26 2007 — edited Nov 26 2007
Hi

I am not able to correctly run the perl file by jsp.

Here is my jsp code:
<%@ page language="java" import="java.io.*" %>
<%
String file = application.getRealPath("/") + "test.pl";


try{
String cmdLine[] = { "perl", "-f", file };

Runtime rt= Runtime.getRuntime();
Process p = rt.exec(cmdLine);

int exitVal = p.waitFor();

p.getInputStream();
p.getOutputStream();
out.print("yes");
out.print(exitVal);
}
catch(Exception e){e.printStackTrace();
out.print("no");
}
%>

Here is the code of test.pl
open (OUT, ">pdbs");
close OUT;

Here is output I receive in browser : yes0

I have placed my jsp file and test.pl in same folder inside tomcat. After getting this output in browser i should get an empty file called 'pdbs' in the folder where test.pl and jsp file is residing. The problem is that I am not to get this empty file. It means that perl script test.pl is not being executed.
If i execute the perl script independently i get the empty file pdbs which is quite obivious.

Can anyone help me out in running perl file inside jsp ?

Thanks in advance
Pankaj
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 24 2007
Added on Nov 26 2007
2 comments
696 views