使用本节中的脚本可自动将活动报表从环境中下载到本地计算机。
可以使用 syncAprReports.bat
下载活动报表。您可以使用 Windows 计划程序来调度批处理文件以自动执行活动报表的下载。有关活动报表的详细信息,请参阅《Oracle Enterprise Performance Management Cloud 管理员入门》中的“使用活动报表和访问日志来监视使用情况”。
您可以手动创建 syncAprReports.bat
,方法是复制以下过程中提供的脚本,然后更新连接参数。此脚本将检查环境,且只下载比本地计算机下载目录中的报表更新的报表。
注:
syncAprReports.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="Ex@mple!" REM set url="https://test-example.stg-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= 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) syncAprReports.bat APR_FolderPath_on_client username password url echo or echo 2) set the parameters in the file and use below syntax echo syncAprReports.bat goto :end :login setlocal DisableDelayedExpansion for /f "delims=" %%i in ('epmautomate login %username% %password% %url%') do set result=%%i if "Login successful" neq "%result%" ( echo Login Failed goto :end ) 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 APR 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,8!" neq "Feedback" ( set isValidFile=false if "!line:~-5!" equ ".html" set isValidFile=true if "!line:~-5!" equ ".json" set isValidFile=true if "!isValidFile!" equ "true" ( 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% APR's downloaded for /L %%n in (1 1 !output_cnt!) DO echo !output[%%n]! goto :end :end cd /D %epmautomate_dir% endlocal
syncAprReports.bat
以设置下表中参数的值。这些值用于访问环境以下载活动报表。
表 3-3 要在 syncAprReports.bat
中包含的参数值
参数 | 预期值 |
---|---|
set apr_dir=%1 |
指定要将活动报表下载到的现有目录。
示例: |
set username=%2 |
用于登录到环境下载活动报表的 Oracle Enterprise Performance Management Cloud 用户名。
示例: |
set password=%3 |
用于存储由 示例:
|
set url=%4 |
环境的 URL。
示例: |
syncAprReports.bat
。有关详细步骤,请参阅“自动执行脚本”。