[EMAIL PROTECTED] wrote: > I'm doing one interface in java that will call some perl scripts. I need to > catch the output and I don't know how to do it. > > If I execute the 'ls' command my java program finnish if I call the perl my > program don't finnish. What am I missing?
What are you expecting from your call to Perl? Note that shelling out has the same dangers with Java as with Perl. > > > import java.io.DataInputStream; > import java.io.IOException; > > public class Test { > public static void main(String[] args) { > try { > Runtime r = Runtime.getRuntime(); > > String[] aStr = {"-e", "'print(\"Ola\n\") foreach (1..100);'"}; > > Process p = r.exec("perl", aStr); You told the system to open the perl compiler here. You may also have Offered it 100 lines like this: "Ola ""Ola Which Perl would have a very hard time interpreting as code. > > //Process p = r.exec("ls"); > > DataInputStream strm = new DataInputStream(p.getInputStream()); > > String str; > while ((str = strm.readLine()) != null){ > System.out.println(str); > } > } catch (IOException e) { > e.printStackTrace(); > } > } > } > > Thanks > Marcos The code above is straight Java. Although it does inicdentally call the Perl interpreter, it is not presented with any further directions, and therefore does nothing. It is probably not the right place to discuss the Java Runtime::exec function. That would be more appropriate on a Java list [use Google to find one] For what it is worth, perl is generally called with a script name or code as the first parameter.. Please learn how to use each language well on its own before you try to develop cross-platform programs. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>