본문 바로가기

IT 연구회

리눅스 shell , was에서 직접 spring url 호출

반응형

linux shell

source 내 main 함수를 활용하여

외부에서 url을 호출하지 않고, was에서 직접 url을 호출하는 방법

shell script를 활용해서 url 호출

#!/bin/sh
cd linux server에서 classes 파일까지 이동 // ex) /azaz/admin/WEB-INF/classes
java -cp .:../lib/* com/oyyat/common/batch/BatchCall /interface/batchSample.do
	public static void main(String[] args) throws MalformedURLException, IOException {
		boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows");
		
		String subUrl = "";
		String baseUrl = "";
		
		for (int ii = 0 ; ii < args.length; ii++) {
			System.out.println("arg >> " + args[ii]);
			if (ii == 0 ) subUrl = args[ii];
		}

		System.out.println("=========================");
		System.out.println(" program   : " + subUrl   );
		System.out.println(" isWindows : " + isWindows);
		
		if (isWindows) {
			baseUrl = BatchCall.getProperties("local.baseUrl");
		}
		else {
			baseUrl = BatchCall.getProperties("server.baseUrl");
		}
		
		String callUrl = baseUrl + subUrl;
		System.out.println(" callUrl : " +callUrl);
		
		try {
			URLConnection connection = getConnect(callUrl);
			InputStream response = connection.getInputStream();
		}
		catch (Exception e) {
			System.out.println(" error ============================");
			e.printStackTrace();
		}
	}

 

 

 

반응형

'IT 연구회' 카테고리의 다른 글

windows에서 배포 파일 생성하기  (0) 2022.07.30
2020 정보처리  (0) 2019.11.13
Access-Control-Allow-Origin  (0) 2018.07.10
[server] Apache 웹서버 설치  (2) 2018.05.17
[기계학습] 알고리즘 도식  (0) 2018.05.16
[WAS] tomcat vs jboss  (0) 2018.05.14
[tomcat] 시작  (0) 2018.05.14
RBAC  (0) 2017.12.30
연산자 종류  (0) 2017.12.24
인터럽트  (0) 2017.12.07