从环境中查找并下载文件

使用本节中的示例脚本可将文本字符串用作通配符从 Oracle Enterprise Performance Management Cloud 环境自动下载一个或多个文件。

使用以下脚本,您可以将您指定为 FILENAME 参数值的字符串与使用 listfiles 命令显示的文件名进行匹配,然后自动下载与该字符串匹配的文件。

确保将适当的搜索字符串分配给 FILENAME 参数。例如,FILENAME="Scheduler Output/epm" 将字符串 Scheduler Output/epmlistfiles 命令在环境中输出的文件名进行匹配,以确定要下载的文件。

用于运行此脚本的输入参数为:usernamepasswordpassword_fileservice_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