지식메모/PlayFramework 2

반응형

자바코드에서 쉘스크립트 실행하기


(Play Framework에서 사용함)


public static Result doShell(String server) { //서버명 받아오기


String result_line = "";

String line = "";

try {

String strScript = "ssh jeong@"+ server +" /usr/local/hello.sh"; //서버명 끼워넣기

Process p = Runtime.getRuntime().exec(strScript); //스크립트 실행


BufferedReader bri = new BufferedReader(new InputStreamReader(

p.getInputStream()));

while ((line = bri.readLine()) != null) { //쉘 스크립트 내용 출력

result_line += line; 

}

} catch (Exception err) {

err.printStackTrace();

}

System.out.println(result_line); //콘솔에서 확인차 

return ok();


}


나도 잘 모르지만 어찌 하다보니 됐다



참고한 블로그 글


http://blog.naver.com/PostView.nhn?blogId=mungyom&logNo=110151707237


반응형

'지식메모 > PlayFramework 2' 카테고리의 다른 글

PlayFramework 2 테스트 방법  (0) 2013.07.17
반응형

해당 프로젝트로 가서 

play

해서 플레이 콘솔창으로 들어간 다음

test

하면 모든 테스트 진행

test-only 폴더명.패키지명.클래스명

상황에 따라

test-only 패키지명.클래스명 

test-only 클래스명

면 특정 클래스만 테스트 진행


플레이프레임워크 사이트에서 설명




반응형

'지식메모 > PlayFramework 2' 카테고리의 다른 글

자바에서 쉘스크립트 실행하기  (0) 2013.07.22

+ Recent posts