이 섹션의 스크립트를 사용하여 환경의 액세스 로그를 로컬 컴퓨터로 다운로드하는 프로세스를 자동화할 수 있습니다.
Windows 스케줄러를 통해 syncAccessLog.bat를 스케줄링하여 로그 파일 다운로드를 자동화할 수 있습니다. 애플리케이션 관리를 사용하여 액세스 로그를 다운로드하는 절차는 관리자용 시작 가이드에서 활동 보고서 및 액세스 로그 보기 및 다운로드를 참조하십시오.
다음 스크립트는 환경을 확인하고 로컬 컴퓨터의 다운로드 디렉토리에서 사용할 수 있는 로그 파일보다 최신 버전인 로그 파일만 다운로드합니다. Windows 스크립트입니다. Linux/UNIX 환경용으로 유사한 쉘 스크립트를 생성할 수 있습니다.
syncAccessLog.bat라는 뱃치(.BAT) 파일을 생성한 후 C:\automate_scripts 등의 편리한 위치에 저장합니다.
주:
비밀번호에 특수 문자가 포함된 경우 특수 문자 처리를 참조하십시오.@echo off
title APR
setlocal DisableDelayedExpansion
REM To hardcode the values in the script replace %1, %2, %3, and %4 with the actual values.
REM Example:
REM set apr_dir="C:\Oracle\apr"
REM set username="serviceAdmin"
REM set password="C:\mySecuredir\password.epw"
REM set url="https://test-cloudpln.pbcs.us1.oraclecloud.com"
set apr_dir=%1
set username=%2
set password=%3
set url=%4
setlocal EnableDelayedExpansion
set epmautomate_dir=%cd%
set lastfile=
REM if [%1]==[] goto :usage
REM if [%2]==[] goto :usage
REM if [%3]==[] goto :usage
set argC=0
for %%x in (%*) do Set /A argC+=1
if %argC% neq 0 (
if %argC% neq 3 (
if %argC% neq 4 (
goto :usage
)
)
)
goto :login
:usage
echo.
echo Invalid syntax. Please check the parameters.
echo Syntax:
echo 1) syncAccessLog.bat APR_FolderPath_on_client username password url
echo or
echo 2) set the parameters in the file and use below syntax
echo syncAccessLog.bat
goto :end
:login
setlocal DisableDelayedExpansion
REM for /f "delims=" %%i in ('epmautomate login %2 %3 %4') do set result=%%i
for /f "delims=" %%i in ('epmautomate login %username% %password% %url%') do set result=%%i
if not exist %apr_dir% (
echo.
echo apr folder does not exist
GOTO :end
)
cd /D %apr_dir%
for /f "delims=" %%D in ('dir /a:d /b /o:-n') do (
REM AFTER: for /f "delims=" %%D in ('dir /a-d /b /s /o:-n') do (
set "lastFile=%%~nD"
goto :next
)
:next
setlocal EnableDelayedExpansion
echo.
echo Most Recent Access Log on client is %lastFile%
set "output_cnt=0"
cd /D %epmautomate_dir%
for /F "delims=" %%f in ('epmautomate listfiles') do (
cd /D !apr_dir!
set "line=%%f"
for /f "tokens=* delims= " %%a in ("!line!") do set line=%%a
if "!line:~0,3!" equ "apr" (
if "!line:~-4!" equ ".zip" (
if "%lastFile%" lss "!line:~4,19!" (
if "!line:~4,19!" neq "!dirname!" (
set apr_dir=!apr_dir:"=!
set /a output_cnt+=1
set "output[!output_cnt!]=!apr_dir!\!line:~4,19!"
set "dirname=!line:~4,19!"
REM start downloading
mkdir "!dirname!"
cd /D !dirname!
echo downloading !line!
set "downloadDir=!apr_dir!\!dirname!"
cd /D %epmautomate_dir%
for /f "delims=" %%i in ('epmautomate downloadfile "!line!"') do set result1=%%i
move "!line:~24!" "!downloadDir!" > nul
echo !result1!
REM end downloading
) else (
REM start downloading
cd /D !dirname!
echo downloading !line!
set apr_dir=!apr_dir:"=!
set "downloadDir=!apr_dir!\!dirname!"
cd /D %epmautomate_dir%
for /f "delims=" %%i in ('epmautomate downloadfile "!line!"') do set result1=%%i
move "!line:~24!" "!downloadDir!" > nul
echo !result1!
REM end downloading
)
) else (
REM TO-DO
)
)
)
)
echo.
echo %output_cnt% access logs downloaded
for /L %%n in (1 1 !output_cnt!) DO echo !output[%%n]!
goto :end
:end
cd /D %epmautomate_dir%
endlocal
syncAccessLog.bat를 수정하여 다음 표의 매개변수 값을 설정합니다. 이러한 값은 환경에 액세스하여 액세스 로그를 다운로드하는 데 사용됩니다.
표 3-4 syncAccessLog.bat에 포함할 변수 값
| 변수 | 예상 값 |
|---|---|
set apr_dir=%1 |
액세스 로그를 다운로드할 디렉토리를 지정합니다.
예: |
set username=%2 |
환경에 로그인하여 액세스 로그를 다운로드하는 데 사용되는 Oracle Fusion Cloud Enterprise Performance Management 사용자 이름입니다.
예: |
set password=%3 |
예:
|
set url=%4 |
환경의 URL입니다.
예: |
syncAccessLog.bat를 스케줄링합니다. 자세한 단계는 스크립트 실행 자동화를 참조하십시오.