Thanks Ashish. This is great.
Chuck Williams
Web Developer
www.sme.org
-----Original Message-----
From: Ashish [SMTP:[EMAIL PROTECTED]]
Sent: Saturday, December 01, 2001 7:55 AM
To: [EMAIL PROTECTED]
Subject: Re: executing perl script in jsp
Charles Williams wrote:
> Any people -- Ashish? -- doing this? I'm sure our people are going to
> be VERY interested.
> chuck williams
Here is the an example of doing 'ls' on the local system and reading the
output sent by the command. You could do the same to run a perl script
and capture its output. Just go over java.lang.Runtime and
java.lang.Process in the Java API Documentation.
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("ls");
// for reading the output of the program
// (out of the program is in for us)
BufferedReader out = new BufferedReader(new
InputStreamReader(p.getInputStream()));
// for reading any output the program sent to err
BufferedReader in = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
// read the output
String line;
while ((line = out.readLine()) != null){
System.out.println(line);
}
// may be you want to do the same for err
also you can get the return value of the program or wait till the
program finished. Just check out java.lang.Process
Ashish Shrestha
--
Ashish Shrestha
Gha 2-482, Balajutar, Kathmandu, Nepal
Phone: 977-1-350593.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com
