2010-06-07 4 views
-2

가능한 중복 :
need help about process…프로세스의 쉘 실행을 피하는 방법은 무엇입니까?

내가 process = Runtime.getRuntime().exec("gnome-terminal"); 같은 프로세스를 시작, 그것은 쉘 실행을 시작합니다. 쉘 실행을 중단하고 I/O를 프로세스에서 리디렉션하고 싶다면 아무에게도이 작업을 수행 할 수 있습니까?

내 코드는 다음과 같습니다

public void start_process() 
    { 
     try 
     { 
      process= Runtime.getRuntime().exec("gnome-terminal"); 
      pw= new PrintWriter(process.getOutputStream(),true); 
      br=new BufferedReader(new InputStreamReader(process.getInputStream())); 
      err=new BufferedReader(new InputStreamReader(process.getErrorStream())); 

     } 
     catch (Exception ioe) 
     { 
      System.out.println("IO Exception-> " + ioe); 
     } 


    } 

public void execution_command() 
    { 

     if(check==2) 
     { 
      try 
      { 
       boolean flag=thread.isAlive(); 
       if(flag==true) 
        thread.stop(); 

       Thread.sleep(30); 
       thread = new MyReader(br,tbOutput,err,check); 
       thread.start(); 

      }catch(Exception ex){ 
       JOptionPane.showMessageDialog(null, ex.getMessage()+"1"); 
      } 
     } 
     else 
     { 
      try 
      { 
       Thread.sleep(30); 
       thread = new MyReader(br,tbOutput,err,check); 
       thread.start(); 
       check=2; 

      }catch(Exception ex){ 
       JOptionPane.showMessageDialog(null, ex.getMessage()+"1"); 
      } 

     } 
    } 

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {           
     // TODO add your handling code here: 
     command=tfCmd.getText().toString().trim(); 

     pw.println(command); 

     execution_command(); 

    }  

I 버튼을 실행 텍스트 필드와 언론에 몇 가지 명령을 입력하면, 아무것도 내가 쉘 실행을 중지하고 입력과 출력을 재 지정할 수 있습니다 어떻게 내 출력 텍스트 영역에 표시되지 않습니다?

+0

중복 된 http://stackoverflow.com/questions/2992801/need-help-about-process - 동일하거나 유사한 질문을 다시 게시하지 마십시오. 대신 원본을 편집하십시오. –

+0

당신은 이미 이것을 물어 봤습니다 –

답변

0

실수로 작성했습니다. process = Runtime.getRuntime(). exec ("bash"); 대신에 process = Runtime.getRuntime(). exec ("gnome-terminal");

+0

제발 답변으로 이런 것들을 게시하지 마시고, 이것을 코멘트로 추가하셔야합니다. 원래 질문에 실수를했다면 ** ** 편집 만 할 수 있습니다. –

관련 문제