How to run Perl script in Java program?

Some say that the following statement can run Perl script in Java program:
Runtime.getRuntime().exec("C:\\runPerl.pl");
But when I run it, it'll throw IOException:
java.io.IOException: CreateProcess: C:\runPerl.pl error=193
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Win32Process.java:63)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:428)
at java.lang.Runtime.exec(Runtime.java:364)
at java.lang.Runtime.exec(Runtime.java:326)
at test.runPerl.main(runPerl.java:16)
Exception in thread "main"
Where is the problem? In fact, I do have a Perl script named "runPerl.pl" in my C:/ directory. Could anybody tell me why it can't be run? Thanks in advance.

Hello sabre,
First of all thanks for your reply.
I have tried like what you mentioned.
Eventhough, i could get the exact error message.
I could get the Exception
"Exception:java.lang.IllegalThreadStateException: process hasn't exited"
<code>
import java.io.*;
public class Sample{
public static void main(String args[]) {
String s = null;
Process p;
try
     p = Runtime.getRuntime().exec("tar -vf sample.tar");
     //p.waitFor();
     if(p.exitValue() == 0)
          System.out.println("CommandSuccessful");
     else
          System.out.println("CommandFailure");
catch(Exception ex)
     System.out.println("Exception:"+ex.toString());
</code>
In this code, i tried to run the "tar command". In this command i have given -vf instead -xvf.
But it is throwing
"Error opening message catalog 'Logging.cat': No such file or directory
Exception:java.lang.IllegalThreadStateException: process hasn't exited
CommandFailure"
"Error opening message catalog 'Logging.cat'" what this line means ie,
I dont know what is Logging.cat could you explain me its urgent.
Thanks in advance.
Rgds
tskarthikeyan

Similar Messages

  • Run Perl script in JAVA

    Can we run perl scripts in java, still supporting perl API?
    Thanks a lot for help!

    I haven't tried it but I think 6.0 supports some
    scripting.But NOT perl!Sorry, I didn't mean some Perl Scripting. I meant some scripting and I wasn't sure what languages.

  • How to run sscript shell with java program

    Hi everybody,
    i want to know how can i do to execute a script shelle (bash) with program java (if it s possible)
    for example this script:
    #!/bin/bash
    echo "hello"
    can i run it with java program or i have to make dome modifications .
    thank you for your help in advance.

    Well, if you want to be portable across platforms, you should write as much code in Java as possible and not rely on native scripts (I'm sure your script is more complex than this 'echo' example ;-) ).
    Having said that, you can use the java.lang.Runtime class and in particular its various exec() methods.
    Try something like this:
    Process p;
    try {
        p = Runtime.getRuntime().exec("myscript.sh");
    } catch (IOException ioe) {
    }You can then "interact" with the spawned process with the Process object returned by the exec method.
    Note you need to have the appropriate security rights.
    For more details, look at the API documentation here:
    http://java.sun.com/j2se/1.4.2/docs/api/
    hth,
    -Alexis

  • How to run perl file from java file..???

    Hi All,
    How to run a perl file from java file.I know that there is one JPL(Java-Perl Library) preprocessor which can be used to do this,but no idea of how to do it..
    Any help is appreciated.
    Thanks in advance.

    viswa07 wrote:
    Ok and any idea regarding JPL..????I don't know it and the first few posts that I found mentioned it using Java 1.1-style JNI calls, which hints at a dead project. And you don't want to use a dead project.

  • How to execute unix script in java program that is on unix .

    hi ,
    I want to call "sendfax" script that is for sending fax to Hylafax server.
    This sendfax script is called in client java program.

    I want to call "sendfax" script that is for sending
    fax to Hylafax server.
    This sendfax script is called in client java program.And what is your problem?

  • How to run the jmeter through java program

    i wnat interact jmeter through my java program
    i will pass values to jmeter through my java program
    i wnat retrive the results from jmeter to my java program

    Read the manual.

  • Run Perl script in my Java program

    Some say that the following statement can run Perl script in Java program:
    Runtime.getRuntime().exec("C:\\runPerl.pl");
    But when I run it, it'll throw IOException:
    java.io.IOException: CreateProcess: C:\runPerl.pl error=193
    at java.lang.Win32Process.create(Native Method)
    at java.lang.Win32Process.<init>(Win32Process.java:63)
    at java.lang.Runtime.execInternal(Native Method)
    at java.lang.Runtime.exec(Runtime.java:566)
    at java.lang.Runtime.exec(Runtime.java:428)
    at java.lang.Runtime.exec(Runtime.java:364)
    at java.lang.Runtime.exec(Runtime.java:326)
    at test.runPerl.main(runPerl.java:16)
    Exception in thread "main"
    Where is the problem? In fact, I do have a Perl script named "runPerl.pl" in my C:/ directory. Why can't it be run?

    Please don't crosspost
    http://forum.java.sun.com/thread.jspa?threadID=703918

  • How can i execute vb scripts in java program

    hi
    how can i execute any batch files or any other exe files (vb scripts) from java programs
    thanks

    Hi,
    You use Runtime.exec to execute commands / exe-files. See the documentation (and remember that it will only work on windows):
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Runtime.html
    /Kaj

  • Can servlets/ jsp automatically run perl scripts and executables?

    I'm a student and am new to to servlets and web programming in general.
    I need to know if it's possible to run perl scripts and executables automatically from servlets/ jsp.
    The program I am planning on creating should have a client outside a firewall that uploads perl files to a gateway machine inside the firewall, the servlet should be able to run this perl file, and then pass the resulting file as an argument to an executable, to be run by another servlet on a different server.
    I've tried looking everwhere for an answer to this and am about to revert to a cgi based approach because I'm not sure if it would work so any help/ suggestions would be much appreciated.

    Hallo,
    I think using java Runtime will help. you can do Processes that execute shell or system commands through
    Process process = Runtime.getRuntime().exec("your perl scripts here!");
    Bye

  • Call PERL script from JAVA

    I am facing a problem in running a PERL script in JAVA in UNIX box..
    I am able to call ther perlscript.
    Perl script has
    #! /usr/local/bin/perl
    print "\nEnter Your Name :";
    $name = <>;
    print "\nYour Name is : $name\n";
    exit 0;
    Perl script request for the INPUT(name) .
    My Java program is
    File perlfile = new File("test.pl");
    Runtime runtime = Runtime.getRuntime();
    Process process = runtime.exec("perl "+perlfile);
    Here is the problem tat IT IS says error =2 ..What has to be the solution so tat i can CALL PERL SCRIPT as similiar to running it separatly in prompt { >perl test.pl }
    PLEASE help me on this....

    In the PERL SCRIPT (test.pl)
    LINE 1 : #! /usr/local/bin/perl
    LINE 2 : print "\nEnter Your Name :"; .
    LINE 3 : $name = <>;
    LINE 4 : print "\nYour Name is : $name\n";
    LINE 5 : exit 0;
    When i run this script in perl test.pl in prompt (UNIX BOX), i am gettin the request for name "Enter Your Name:____ " but when i call this script from Java it doesn't request for name and moreover the process doesnt ends (use ctrl+c to come out of the process).When i come out forcefully it shows the ERROR=2.
    My requirement is such tat need to call a PERL SCRIPT from java so tat java process give the control to PERL script and it will continue the process..
    Sample scenario:
    Java move a file and store it in a new FOLDER
    MY perl script will read the file in new FOLDER.
    here the perl script will get the file name for processing... My issue comes here .$name is not be prompted while calling thro java..

  • Converting Perl Scripts into Java Servlets

    Hello,
    I have just been assigned the job of converting some perl scripts into Java Servlets. The first problem i have run into is with quotes. The problem is in perl you can just print out blocks of html without worrying about the quotes. ie (name="joe"). It will be a pain if i have to delimit every quote that is in the html so that i can add it to my java string. I was just wondering if anyone knows of an easy way of accomplishing this task.
    Thanks,
    Jon

    jonhorsman said
       I have just been assigned the job of converting some perl
       scripts into Java Servlets.I was just wondering if anyone
       knows of an easy way of accomplishing this task. The easy way is to not do it - is there a business need to do this or just because someone likes java more than perl.
    But presuming there is a business need, then the easist way I can think (and certainly more interesting than doing it by hand) is to write a perl script that does it for you.

  • Is it possible to execute SAPGUI scripts from java program?

    Hi everyone..
         I need to develop an java applications that executes the SAPGUI script or any technique that execute set of transaction as client.
         Is it possible to execute SAPGUI scripts from java program? if so, how it can be achieved? is there any other technique to achieve above mention scenario?.
         it will be more helpful, if docs related to that are shared..
         Thanks in advance

    Oh, bummer. Would be much more convenient if I could just use iTunes for everything. Can't stand WMP. I wonder if WinAmp might be a good compromise?
    Thanks for this answer . . .
    Sharon

  • How to read system eventlog using java program in windows?

    How to read system eventlog using java program in windows?
    is there any java class available to do this ? or any one having sample code for this?
    Your friend Zoe

    Hi,
    There is no java class for reading event log in windows, so we can do one thing we can use windows system 32 VBS script to read the system log .
    The output of this command can be read using java program....
    we can use java exec for executing this system32 vbs script.
    use the below program and pass the command "eventquery"
    plz refer cscript,wscript
    import java.io.*;
    public class CmdExec {
    public static void main(String argv[]) {
    try {
    String line;
    Process p = Runtime.getRuntime().exec("Command");
    BufferedReader input =
    new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    System.out.println(line);
    input.close();
    catch (Exception err) {
    err.printStackTrace();
    This sample program will list all the system log information....
    Zoe

  • Help--How can I open only one java program at one time?

    How can I open only one java program(same program) in Windows at one time?

    In Java 1.5, you can use the JVM's own monitoring APIs to examine what other JVMs are running on the system, and what applications they're running.
    It's general and powerful, but complex. The socket/file/whatever approach is cleaner, and probably more suited to your usage.
    Don't bother trying to use the Windows task manager for this sort of thing. You have to write messy native code, and it isn't reliable after all that anyway.

  • How to run function(s) on ANY program exit?

    I can easily do this when someone selects "Exit" from the program's menu, with this code:
    AllSortsOfExitCode()
    System.out.println("Ok, everything is wrapped up. Now we will end the program.");
    System.exit(0);
    BUT...how do you get this code to run when someone clicks the little X in the upper-right hand corner?
    I can't figure out how to do that.
    I need to override the class destructor or something, but I don't think Java has destructors in the classic sense. I found one 4-page thread about "Java destructors" but it was just an argument between a couple people -- I didn't learn anything from it.
    Thanks,
    Matthew

    CathInfo wrote:
    BUT...how do you get this code to run when someone clicks the little X in the upper-right hand corner?
    Thanks,
    MatthewThe earlier replies cover the case you described above. But your thread title says something else:
    How to run function(s) on ANY program exit?Answer - you can't. Power loss can't be handled. Shutdoen hooks can help with most other conditions, see
    http://www.google.com/search?num=100&hl=en&c2coff=1&q=java+shutdown+hook&btnG=Search

Maybe you are looking for

  • Why am I getting half a dozen "Chrome" errors with v10.0.1?

    Since the last update to v10.0.1, running on WinXP, I've been getting half a dozen errors each time I try to open a Firefox window. All seem to involve Chrome, which I have made a practice of trying to keep as far away from my computers as possible.

  • App Builder/Run Time Install Broke?

    I have full up version of LabView 5.1.1, running on Win98. I went through the Application Building Example on page 12 of the Application Buidler release notes. I then installed the sample app on another Win98 box. The application installation went OK

  • Editable records in list output.

    dear gurus, i have a small query regarding lists. how can we make the list output entries editable and once i edit a field it has to be updated in the internal table and a new list should be shown with the changes made in the list. any sort of help i

  • Netboot and wireless, can it be done?

    Hi, just trying out some network changes. And had a free port on my server so put it on our wireless network. Is it possible to get netboot working over Airport or are there restrictions? Didn't succeed and couldn't see anything obvious in the logs t

  • CAN'T SETUP MAIL IN NOKIA X3-02

    MY NOKIA X3-02 HAS BEEN REPLACED BY NOKIA BECAUSE OF SOME PROBLEM. AND FROM THE TIME I HAVE GOT MY NEW NOKIA X3-02 FROM NOKIA CARE I CAN'T SET UP MAIL IN MY CELL PHONE. EVERYTIME WHEN I CLICK ON "SET UP MAIL" AND ACCEPTS ITS TERMS AND CONDITIONS IT S