how to run external perl script through jsp
843829Nov 26 2007 — edited Nov 26 2007Hi
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