Loading ...
Sorry, an error occurred while loading the content.
 

how to invoke a Perl script from Java Program.

Expand Messages
  • Chen Shapira
    ... Anyone knows a better way to do that?
    Message 1 of 2 , Jul 13, 2000
      > Below is an example how to invoke a Perl script from
      > Java program. Take your attention that this program
      > - sets the workDir directory.
      > - invokes the Perl runtime through a .bat script.
      > All the sources are supplied.
      >
      > import java.io.*;
      >
      > public class Test {
      > public static void main(String[] args) {
      > String[] cmd = new String[3];
      > cmd[0] = "command.com";
      > cmd[1] = "/C";
      > cmd[2] = "runPerl.bat";
      > String[] param = {""};
      > File workDir = new File("d:/perl");
      > try {
      > Process p = Runtime.getRuntime().exec(cmd, param, workDir);
      > BufferedReader br = new BufferedReader(new
      > InputStreamReader(p.getInputStream()));
      > String line;
      > while ((line = br.readLine()) != null) {
      > System.out.println(line);
      > }
      > br.close();
      > } catch(Exception ex) { System.out.println("Can not execute: " +
      > ex.toString()); }
      > System.out.println("Done!");
      > }
      > }
      >
      > REM runPerl.bat Source
      > @echo off
      > D:\Perl\perl D:\Perl\helloWorld.pl
      >
      > ## helloWorld.pl Source
      > print "Hello World!\n";

      Anyone knows a better way to do that?
    • Shlomi Fish
      What s wrong with using perl as the first command or d: perl perl , etc. Check that perl is properly installed on your system. Regards, Shlomi Fish ...
      Message 2 of 2 , Jul 14, 2000
        What's wrong with using "perl" as the first command or "d:\perl\perl",
        etc.

        Check that perl is properly installed on your system.

        Regards,

        Shlomi Fish



        ----------------------------------------------------------------------
        Shlomi Fish shlomif@...
        Home Page: http://t2.technion.ac.il/~shlomif/
        Home E-mail: shlomif@...

        The prefix "God Said" has the extraordinary logical property of
        converting any statement that follows it into a true one.
      Your message has been successfully submitted and would be delivered to recipients shortly.