codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  activate perl file during java file  bwp_81 at 18:40 on Friday, August 05, 2005
 

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.



  Re: activate perl file during java file  javabits at 21:37 on Friday, August 05, 2005
 

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...

  Re: activate perl file during java file  bwp_81 at 12:23 on Tuesday, August 09, 2005
 

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

  Re: activate perl file during java file  javabits at 19:16 on Tuesday, August 09, 2005
 

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...








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  For better design, please vote!
•  Re: dynamic crystal report generation
•  Finding File Size and Creating Error log
•  Ajax example: online chat
•  Re: Nested Javascripts
•  ISP says linefeeds are causing problems
•  Linker Error Unresolved External Borland Builder 2006
•  Have multiple ASP.NET web projects share pages and controls
•  Re: How can I read ASCII data file in C++


Recent Articles
What is a pointer in C?
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net


© Copyright codetoad.com 2001-2006