I need help in executing perl script from java in linux

Discussion in 'Java' started by amarpreetsinghgill, Feb 25, 2008.

  1. amarpreetsinghgill

    amarpreetsinghgill

    Joined:
    Feb 25, 2008
    Messages:
    1
    Hi all,
    I am using the following java code to invoke a perl script named helloworld.pl. When i run the perl script individually, it displays "Hello world" on the console, but it is unable to produce the same o/p when called from java. It does nothing and no o/p is displayed. I dont know what im doing wrong.

    ---------- Java code -------------
    import java.io.IOException;
    class Test
    {
    public static void main (String [] args)
    {
    try {
    String cmdString
    = "perl /home/admin/helloworld.pl";
    Runtime.getRuntime().exec(cmdString);
    }
    catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }
    ------------------------------------------------------------------------
    -------------------- Perl Code -----------------
    #!/usr/bin/perl -I/usr/local/lib/site_perl

    print "hello world";
    -------------------------------------------------------------------------

    Please help me guys.....
    amarpreetsinghgill, Feb 25, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dpackwood
    Replies:
    3
    Views:
    1,757
  2. jaywelbourn@gmail.com

    executing linux shell script from within c++.net

    jaywelbourn@gmail.com, Jul 23, 2007, in forum: C++
    Replies:
    1
    Views:
    357
    Victor Bazarov
    Jul 23, 2007
  3. /usr/ceo
    Replies:
    32
    Views:
    1,879
    Mark Space
    Sep 15, 2008
  4. mickeyteg
    Replies:
    0
    Views:
    567
    mickeyteg
    Nov 4, 2010
  5. nilesh.sonawane@gmail.com
    Replies:
    3
    Views:
    172
    Josef Moellers
    Nov 1, 2007
Loading...

Share This Page