Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > I need help in executing perl script from java in linux

Reply
Thread Tools

I need help in executing perl script from java in linux

 
 
amarpreetsinghgill amarpreetsinghgill is offline
Junior Member
Join Date: Feb 2008
Posts: 1
 
      02-25-2008
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.....
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Pro but Java Newbie: Need nudge in proper direction for myfavorite Perl routine in Java /usr/ceo Java 32 09-15-2008 12:12 AM
Issue in executing more than one perl script from Single perl script nilesh.sonawane@gmail.com Perl Misc 3 11-01-2007 06:19 PM
executing linux shell script from within c++.net jaywelbourn@gmail.com C++ 1 07-23-2007 02:25 PM
Problem in executing a script on the server side ! Script found but nothing executed ! CÚdric RossÚ ASP .Net 1 11-09-2004 09:43 AM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM



Advertisments