2014-09-27 19 views
0

에코 인쇄하지 않습니다자바 쉘 내가 사용하는 쉘 스크립트를 실행하는거야

Runtime.getRuntime().exec(command); 

모든 출력에 대한 exept, 잘 작동합니다. 그래서,이 스크립트

gedit를 엽니 다. 그러나 Java에서 실행하면 출력이 나지 않습니다. 문제가 무엇입니까?

+1

에서 언급 한 바와 같이? –

+0

가능한 [Print Runtime exec() OutputStream to console] (http://stackoverflow.com/questions/3936023/printing-runtime-exec-outputstream-to-console) –

답변

0
String line; 
    Process p = Runtime.getRuntime().exec(...); 
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); 
    while ((line = input.readLine()) != null) { 
    System.out.println(line); 
    } 
    input.close(); 

당신은 출력과 이유를 볼 것으로 예상 할 Printing Runtime exec() OutputStream to console

관련 문제