從環境移除不需要的檔案

使用這些指令碼從環境移除不必要的檔案。

這些指令碼會執行下列步驟:

  • 登入環境。
  • 列出環境中的檔案與快照。
  • 刪除 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