aspose file tools*
The moose likes Java in General and the fly likes calling a perl script from java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "calling a perl script from java program" Watch "calling a perl script from java program" New topic
Author

calling a perl script from java program

Ishita Saha
Ranch Hand

Joined: May 30, 2007
Posts: 39
Hi,

I need to execute a perl script from a java program, I got some stuff on google:


It gives me the output as: Command Successful
but I need to see the output which should be: "I have a no" (which is there in basic.pl)

also I tried running another script - which should create a txt file ( that is not happening either)

any help is appreciated.
Thanks!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
You need to "drain" both Streams associated with the Process, not only the input stream. The ProcessBuilder class makes that a little easier in Java5, but you can get all sorts of problems with Processes if you don't start a parallel thread. For details look for Michael Daconta's classic article "When Runtime.exec() won't"
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12683
    
    5
When running a Process, you should provide for consuming both std out and std err streams. Your code waits for the Process to end, but does not consume the output while the process is running. This is a recipe for disaster since the process may hang trying to output to std out or std err.

Bill

Java Resources at www.wbrogden.com
 
Consider Paul's rocket mass heater.
 
subject: calling a perl script from java program
 
Similar Threads
Communicating with unix command process from java using stream
java program run external command on Unix
help with running dos commands using java
I want to login ( using Telnet ) to a Unix server
why can't see the output in dos window after using buffered reader..??