从环境中删除不必要的文件

使用这些脚本可从环境中删除不必要的文件。

这些脚本执行以下步骤:

  • 登录环境。
  • 列出环境中的文件和快照。
  • 删除 input.properties 中指定的文件。
  • 注销。

Windows 示例脚本

通过复制以下脚本来创建一个名为 removeUnnecessaryFiles.ps1 的文件。将其存储在本地目录中。

$inputproperties = ConvertFrom-StringData(Get-Content ./input.properties -raw)
$username="$($inputproperties.username)"
$passwordfile="$($inputproperties.passwordfile)"
$serviceURL="$($inputproperties.serviceURL)"
$file1="$($inputproperties.file1)"
$file2="$($inputproperties.file2)"

epmautomate login ${username} ${passwordfile} ${serviceURL}
epmautomate listfiles
epmautomate deletefile ${file1}
epmautomate deletefile ${file2}
epmautomate logout

Linux/UNIX 示例脚本

通过复制以下脚本来创建一个名为 removeUnnecessaryFiles.sh 的文件。将其存储在本地目录中。

#!/bin/bash
. ./input.properties
export JAVA_HOME=${javahome}
${epmautomatescript} login "${username}" "${passwordfile}" "${serviceURL}"
${epmautomatescript} listfiles
${epmautomatescript} deletefile "${file1}"
${epmautomatescript} deletefile "${file2}"
${epmautomatescript} logout

创建 input.properties 文件

要运行 removeUnnecessaryFiles 脚本,请创建 input.properties 文件并使用环境信息进行相应的更新。将文件保存在存储 removeUnnecessaryFiles.ps1removeUnnecessaryFiles.sh 的目录中。

Windows

username=exampleAdmin
passwordfile=examplePassword.epw
serviceURL=exampleURL
file1=FILE_NAME
file2=FILE_NAME

Linux/UNIX

javahome=JAVA_HOME
epmautomatescript=EPM_AUTOMATE_LOCATION
username=exampleAdmin
passwordfile=examplePassword.epw
serviceURL=exampleURL
file1=FILE_NAME
file2=FILE_NAME

表 3-7 input.properties 参数

参数 说明
javahome JAVA_HOME 位置。仅限 Linux/UNIX。
epmautomatescript EPM Automate 可执行文件 (epmautomate.sh) 的绝对路径。仅限 Linux/UNIX。
username 同时具有身份域管理员角色的服务管理员的用户名。
password 服务管理员的密码或加密密码文件的名称和位置。
serviceURL 要从其生成快照的环境的 URL。
file1file2 要从环境中删除的文件或快照的名称。如果文件不在发件箱中,请指定文件的路径和名称。
   

重新运行该脚本

  1. 通过复制上一节的脚本来创建 removeUnnecessaryFiles.ps1removeUnnecessaryFiles.sh
  2. 创建 input.properties 文件,并将其保存在 removeUnnecessaryFiles 脚本所在的目录中。此文件的内容因操作系统的不同而异。请参阅“创建 input.properties 文件”。

    请确保您对此目录具有写权限。对于 Windows,您可能需要使用以管理员身份运行选项启动 PowerShell,以便能够运行脚本。

  3. 启动脚本。
    • Windows PowerShell:运行 removeUnnecessaryFiles.ps1
    • Linux/UNIX:运行 ./removeUnnecessaryFiles.sh