Results 1 to 6 of 6

Thread: Perl in Java!

  1. #1
    hakan123 is offline Member
    Join Date
    Nov 2009
    Posts
    13
    Rep Power
    0

    Default Perl in Java!

    Hello All!
    I am new to java. i want to run my perl script from java. i dont know what mistake i am doing, i am not able to execute my perl script. i can call my perl script with two arguments. i am able to run it successfully when i made a batch file. i dont know why it is not working in java. following is the code.

    try
    {
    pathn1 = "C:\\Program Files\\jambo\\gritchy\\kakae";
    fname1 = alpine.wav ;
    Process p = Runtime.getRuntime().exec("C:/perl/bin/perl.exe C:\\Perl\\scripts\\varm.pl \"pathn1\" fname1");
    int fg = p.waitFor();
    if (fg == 0)
    {
    loginfo("successfull");
    }

    else {
    loginfo("failed");
    }

    }
    catch(Exception e)
    {
    loginfo("Exception running varm");
    }

    Please help me

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,655
    Blog Entries
    7
    Rep Power
    21

    Default

    Print out the string you want to exec() and you'll see what is wrong with it.

    kind regards,

    Jos

  3. #3
    hakan123 is offline Member
    Join Date
    Nov 2009
    Posts
    13
    Rep Power
    0

    Default

    Thanks Joash!
    i printed it out, i see the problem that its taking pathn1, fname1 as strings. how can i make it take the assigned strings, please help!

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,655
    Blog Entries
    7
    Rep Power
    21

    Default

    Use one of the other exec( ... ) methods that are more convenient for you.

    kind regards,

    Jos

  5. #5
    hakan123 is offline Member
    Join Date
    Nov 2009
    Posts
    13
    Rep Power
    0

    Default thanks

    Thanks jos!
    and im looking for that convineant method:(...

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,655
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by hakan123 View Post
    Thanks jos!
    and im looking for that convineant method:(...
    Try this one from the Runtime class: exec(String[] cmdarray). Also read the API documentation for that class.

    kind regards,

    Jos

Similar Threads

  1. Replies: 1
    Last Post: 01-07-2011, 07:20 AM
  2. [B] How to call Perl script from Java [/B]
    By JavaEmpires in forum Advanced Java
    Replies: 7
    Last Post: 12-19-2008, 03:10 PM
  3. run perl script from java
    By maheshmhs in forum New To Java
    Replies: 0
    Last Post: 12-19-2008, 12:40 PM
  4. Use Perl function with java
    By lenny in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 06:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •