Often we come across procedures which need to be performed by issuing commands in a telnet session. 종종 우리는 전체 절차를 수행할 필요가 텔넷 세션에서 명령을 발행합니다. It is relatively easy to do it manually but is definitely not suitable for automation. 그것은 상대적으로 쉬운 일은 아닙니다 적합하지 않다는 자동화를 수동으로하지만 분명히합니다. Let’s see how you can easily automate such tasks using Java software. 어디 보자 같은 작업을 자동화할 수있는 방법에 쉽게 자바 소프트웨어를 사용합니다. Sample code included. 예제 코드를 포함합니다.

Here is the core code: 여기서의 핵심 코드 :

// Conversation; Simulating telnet session with James server / / 회화, 제임스 서버로 텔넷 세션을 시뮬레이트
readLines(r, 3); readlines (연구, 3);
writeLine(w, login); writeline (폭, 로그인);
readLines(r, 1); readlines (연구, 1);
writeLine(w, password); writeline (폭, 비밀 번호);
readLines(r, 1); readlines (연구, 1);
writeLine(w, SHUTDOWN); writeline (폭, 종료);
readLines(r, 1); readlines (연구, 1);

readLines() reads and discards specified number of lines (response). readlines () 읽기 및 폐기 지정된 수의 행 (응답).

Here are the key functions: 주요 기능은 다음과 같습니다 :

 /** Read and discard count lines from BufferedReader r */     public static void readLines(BufferedReader r, int count) throws IOException {         for(int i = 0;i < count;i++) {             String t = r.readLine();             if(DEBUG) System.out.println(t);         }     }      /** Write out to BufferedWriter w and flush */     public static void writeLine(BufferedWriter w, String out) throws IOException {         w.write(out + CRLF, 0, (out + CRLF).length());         w.flush();     } / ** bufferedreader 연구에서 읽기 및 폐기 카운트 라인 * / 공공 정적 무효 readlines (bufferedreader 연구, int 수) ioexception (에 대한 예외 (int 전 = 0; 나는 <카운트; 나는 + +) (문자열을 t = r.readline (); 만약 (디버그) system.out.println (t);)) / ** bufferedwriter 승 및 플래시를 작성 * / 공공 정적 무효 writeline (bufferedwriter 승, 문자열 아웃) 예외 ioexception (w.write (아웃 + crlf, 0 , (아웃 + crlf). 길이 ()); w.flush ();) 

You can download the code 코드를 다운로드하실 수있습니다 here 여기에 . 합니다. It is used to shutdown Apache James Mail Server. 그것을 사용하여 아파치 제임스 메일 서버를 종료합니다. The utility is fully described along with the options in - 이 유틸리티는 완전하게 설명과 함께 옵션이 - Shutdown Apache James Mail Server - Java Utility 아파치 제임스 메일 서버를 종료 - 자바 유틸리티