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?

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);
            //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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to