使用本節中的範例指令碼,以自動執行使用文字字串作為萬用字元從 Oracle Enterprise Performance Management Cloud 環境中下載一或多個檔案的程序。
下列指令碼可讓您比對您指定作為 FILENAME
參數值的字串和使用 listfiles
命令顯示的檔案名稱,然後自動下載與字串相符的檔案。
請確定對 FILENAME
參數指派適當的搜尋字串。例如,FILENAME="Scheduler Output/epm"
可符合您的環境中的 listfiles
命令輸出的檔案名稱中的字串 Scheduler Output/epm
,而識別出要下載的檔案。
執行此指令碼的輸入參數包括 username
、password
或 password_file
和 service_url
。
註:
如果密碼包含特殊字元,請參閱處理特殊字元。Windows
@echo off setlocal EnableExtensions EnableDelayedExpansion set USERNAME="username" set PASSWORD="password" set URL="url" call epmautomate login %USERNAME% %PASSWORD% %URL% set FILENAME="Scheduler Output/epm" for /f "tokens=*" %%i in ('epmautomate listfiles ^| findstr /b /r /c:"^ *%FILENAME%" ') do ( call epmautomate downloadfile "%%i" ) call epmautomate logout endlocal
Linux/UNIX
#!/bin/sh USERNAME="username" PASSWORD="password" URL="url" ./epmautomate.sh login $USERNAME $PASSWORD $URL FILENAME='Scheduler Output/epm' #echo $FILENAME ./epmautomate.sh listfiles | grep "^ $FILENAME" | while read -r line ; do echo "Processing $line" ./epmautomate.sh downloadfile "$line" done ./epmautomate.sh logout