|
Hi
I am making a generator in java for a hardware design. Some of the hardware modules are parameterisable while i have generator for othes. These generators are in perl language. i have to invoke these generator during execution. Can u tell how i can activate perl files through java.
|
|
|
Something like this should work. Note the location of your perl might be different.
import java.io.*;
public class CmdExec
{
public CmdExec(String cmdline)
{
try
{
String line;
Process p = Runtime.getRuntime().exec(cmdline);
BufferedReader input = new BufferedReader
(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null)
{
System.out.println(line);
}
input.close();
}
catch (Exception err)
{
err.printStackTrace();
}
}
public static void main(String argv[])
{
new CmdExec("/usr/bin/perl_sample.html");
}
}
semper fi...
|
|
|
Hi
Thanx for the help.I am bit now in perl stuf. I have tried your given java code. It works fine for *.exe files but gives problem when we use it for .pl file. Can give some other clue.
When I run perl file on C prompt it works fine but it does not work while activating it in java program using Runtime.getRuntime().exec(command);
Thanx
With Regards
Omer
|
|
|
What is the command string you are passing?
If you look at the example, you need to invoke your perl interpreter with the name of your perl script. If you call your perl script directly the command will fail.
So in the example the command issued is:
"/usr/bin/perl_sample.html"
/usr/bin/perl is the location of the perl interpreter
and
sample.pl is the actual perl script that is going to be executed.
semper fi...
|
|
|