IRunUtil

public interface IRunUtil

com.android.tradefed.util.IRunUtil


用於執行定時作業和系統指令的介面。

摘要

巢狀類別

interface IRunUtil.IRunnableResult

此介面可用於以非同步方式執行會傳回布林值狀態的作業。 

公用方法

abstract void allowInterrupt(boolean allow)

允許/禁止在目前執行緒上中斷執行。

abstract void interrupt(Thread thread, String message, ErrorIdentifier errorId)

中斷指定執行緒進行中/即將執行的執行作業。

abstract void interrupt(Thread thread, String message)

中斷指定執行緒進行中/即將執行的執行作業。

abstract boolean isInterruptAllowed()

指定 RunUtil 的中斷狀態。

abstract Process runCmdInBackground(Redirect redirect, command)

替代的 runCmdInBackground(String) 方法,可接受 ERROR(/List) 形式中的指令引數。

abstract Process runCmdInBackground( command)

替代的 runCmdInBackground(String) 方法,可接受 ERROR(/List) 形式中的指令引數。

abstract Process runCmdInBackground( command, OutputStream output)

使用 ERROR(/OutputStream) 執行指令,記錄指令輸出內容。

abstract Process runCmdInBackground(String... command)

以非同步方式執行系統指令的輔助方法。

abstract Process runCmdInBackground(Redirect redirect, String... command)

以非同步方式執行系統指令的輔助方法。

abstract boolean runEscalatingTimedRetry(long opTimeout, long initialPollInterval, long maxPollInterval, long maxTime, IRunUtil.IRunnableResult runnable)

多次封鎖並執行一項作業,直到成功為止。

abstract boolean runFixedTimedRetry(long opTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable)

多次封鎖並執行一項作業,直到成功為止。

abstract boolean runFixedTimedRetryWithOutputMonitor(long opTimeout, long idleOutputTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable)

多次封鎖並執行一項作業,直到成功為止。

abstract CommandStatus runTimed(long timeout, IRunUtil.IRunnableResult runnable, boolean logErrors)

封鎖並執行作業,如果作業時間超過指定時間,就會取消作業。

abstract CommandResult runTimedCmd(long timeout, OutputStream stdout, OutputStream stderr, String... command)

執行系統指令的輔助方法,如果執行時間超過指定時間,則會取消,並將輸出內容重新導向至檔案 (如有指定)。

abstract CommandResult runTimedCmd(long timeout, String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。

abstract CommandResult runTimedCmdRetry(long timeout, long retryInterval, int attempts, String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。

abstract CommandResult runTimedCmdRetryWithOutputMonitor(long timeout, long idleOutputTimeout, long retryInterval, int attempts, String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。

abstract CommandResult runTimedCmdSilently(long timeout, String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。

abstract CommandResult runTimedCmdSilentlyRetry(long timeout, long retryInterval, int attempts, String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。

abstract CommandResult runTimedCmdWithInput(long timeout, String input, File stdoutFile, File stderrFile, String... command)

執行系統指令的輔助方法,如果執行時間超過指定時間,則會取消,並將輸出內容重新導向至檔案 (如有指定)。

abstract CommandResult runTimedCmdWithInput(long timeout, String input, String... command)

輔助方法可執行需要 stdin 輸入的系統指令,並在所需時間超過指定時間時取消。

abstract CommandResult runTimedCmdWithInput(long timeout, String input, command)

輔助方法可執行需要 stdin 輸入的系統指令,並在所需時間超過指定時間時取消。

abstract CommandResult runTimedCmdWithInputRedirect(long timeout, File inputRedirect, String... command)

輔助方法執行系統指令,需要從檔案重新導向 Stdin,並在所需時間超過指定時間時取消作業。

abstract CommandResult runTimedCmdWithOutputMonitor(long timeout, long idleOutputTimeout, OutputStream stdout, OutputStream stderr, String... command)

執行系統指令的輔助方法,如果執行時間超過指定時間,則會取消,並將輸出內容重新導向至檔案 (如有指定)。

abstract CommandResult runTimedCmdWithOutputMonitor(long timeout, long idleOutputTimeout, String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。

abstract CommandResult runTimedCmdWithOutputMonitor(long timeout, long idleOutputTimeout, OutputStream stdout, OutputStream stderr, ICacheClient cacheClient, String... command)

透過快取執行系統指令的輔助方法。

abstract boolean runTimedRetry(long opTimeout, long pollInterval, int attempts, IRunUtil.IRunnableResult runnable)

多次封鎖並執行一項作業,直到成功為止。

abstract boolean runTimedRetryWithOutputMonitor(long opTimeout, long idleOutputTimeout, long pollInterval, int attempts, IRunUtil.IRunnableResult runnable)

多次封鎖並執行一項作業,直到成功為止。

abstract CommandStatus runTimedWithOutputMonitor(long timeout, long idleOutputTimeout, IRunUtil.IRunnableResult runnable, boolean logErrors)

封鎖並執行作業,如果作業時間超過指定時間,就會取消作業。

abstract void setEnvVariable(String key, String value)

設定執行系統指令時要使用的環境變數。

abstract void setEnvVariablePriority(IRunUtil.EnvPriority priority)

決定建立程序時,取消設定環境變數的優先順序是否高於設定值。

abstract void setInterruptibleInFuture(Thread thread, long timeMs)

設為等待一段時間後可中斷。

abstract void setLinuxInterruptProcess(boolean interrupt)

允許在達到逾時時,在透過 #runTimed 方法執行的程序中使用 Linux「kill」中斷。

abstract void setRedirectStderrToStdout(boolean redirect)

設定標準錯誤串流,讓系統在執行系統指令時重新導向至標準輸出串流。

abstract void setWorkingDir(File dir)

設定系統指令的工作目錄。

abstract void sleep(long time)

輔助方法:在指定時間入睡,忽略任何例外狀況。

abstract void unsetEnvVariable(String key)

取消設定環境變數,如此一來,系統指令就會在沒有這個環境變數的情況下執行。

公用方法

允許中斷

public abstract void allowInterrupt (boolean allow)

允許/禁止在目前執行緒上執行中斷。如果允許,則可透過 interrupt(Thread, String) 方法,從其他執行緒中斷目前執行緒的作業。

參數
allow boolean:是否允許目前執行緒上的執行作業中斷。

中斷

public abstract void interrupt (Thread thread, 
                String message, 
                ErrorIdentifier errorId)

中斷指定執行緒進行中/即將執行的執行作業。指定執行緒上的執行作業會擲回 RunInterruptedException

參數
message StringRunInterruptedException 的訊息。

errorId ErrorIdentifier:代表中斷原因 (如果已知)。

中斷

public abstract void interrupt (Thread thread, 
                String message)

中斷指定執行緒進行中/即將執行的執行作業。指定執行緒上的執行作業會擲回 RunInterruptedException

參數
message StringRunInterruptedException 的訊息。

isInterruptAllowed 是否允許

public abstract boolean isInterruptAllowed ()

指定 RunUtil 的中斷狀態。

傳回
boolean 如果執行可以中斷,傳回 true,否則傳回 false。

runCmdInBackground

public abstract Process runCmdInBackground (Redirect redirect, 
                 command)

runCmdInBackground(String) 替代方法,可接受 ERROR(/List) 形式中的指令引數。

參數
redirect Redirect:要套用至 ProcessBuilderERROR(/Redirect)

command :包含指定系統指令和 exec 的選用引數的 ERROR(/List)

傳回
Process 已執行指令的 Process

擲回
如果指令無法執行

runCmdInBackground

public abstract Process runCmdInBackground ( command)

runCmdInBackground(String) 替代方法,可接受 ERROR(/List) 形式中的指令引數。

參數
command :包含指定系統指令和 exec 的選用引數的 ERROR(/List)

傳回
Process 已執行指令的 Process

擲回
如果指令無法執行

runCmdInBackground

public abstract Process runCmdInBackground ( command, 
                OutputStream output)

使用 ERROR(/OutputStream) 執行指令,記錄指令輸出內容。Stdout 和 stderr 會合併在一起。

參數
command :要執行的指令

output OutputStream:用於儲存輸出內容的 OutputStream

傳回
Process 執行指令的 Process

擲回
IOException

runCmdInBackground

public abstract Process runCmdInBackground (String... command)

以非同步方式執行系統指令的輔助方法。

會在啟動指令後立即傳回。

參數
command String:指定的系統指令和 exec 的選用引數

傳回
Process 已執行指令的 Process

擲回
如果指令無法執行

runCmdInBackground

public abstract Process runCmdInBackground (Redirect redirect, 
                String... command)

以非同步方式執行系統指令的輔助方法。

會在啟動指令後立即傳回。

參數
redirect Redirect:要套用至 ProcessBuilderERROR(/Redirect)

command String:指定的系統指令和 exec 的選用引數

傳回
Process 已執行指令的 Process

擲回
如果指令無法執行

runEscalatingTimed 重試

public abstract boolean runEscalatingTimedRetry (long opTimeout, 
                long initialPollInterval, 
                long maxPollInterval, 
                long maxTime, 
                IRunUtil.IRunnableResult runnable)

多次封鎖並執行作業,直到成功為止。

每次嘗試執行作業之間的等待時間會指數增加。這個 ID 可用於執行輪詢伺服器等作業,以便在服務暫時無法使用時提供復原時間。

參數
opTimeout long:單一作業嘗試的等待時間上限 (毫秒)

initialPollInterval long:嘗試執行兩次作業時,等待的初始時間

maxPollInterval long:嘗試作業之間等待的時間上限

maxTime long:嘗試執行作業的總時間約略值

runnable IRunUtil.IRunnableResult:要執行的 IRunUtil.IRunnableResult

傳回
boolean 如果作業在 maxTime 到期前成功完成,則為 true

runFixedTimed 重試

public abstract boolean runFixedTimedRetry (long opTimeout, 
                long pollInterval, 
                long maxTime, 
                IRunUtil.IRunnableResult runnable)

多次封鎖並執行一項作業,直到成功為止。

參數
opTimeout long:單一作業嘗試的等待時間上限 (毫秒)

pollInterval long:嘗試執行兩次作業時,等待的初始時間

maxTime long:嘗試執行作業的總時間約略值

runnable IRunUtil.IRunnableResult:要執行的 IRunUtil.IRunnableResult

傳回
boolean 如果作業在 maxTime 到期前成功完成,則為 true

runFixedTimed 重試 WithOutputMonitor

public abstract boolean runFixedTimedRetryWithOutputMonitor (long opTimeout, 
                long idleOutputTimeout, 
                long pollInterval, 
                long maxTime, 
                IRunUtil.IRunnableResult runnable)

多次封鎖並執行一項作業,直到成功為止。還會監控活動的輸出串流,如果在指定時間未觀察到串流活動時取消,則取消串流。如果閒置輸出逾時設為零,就不會發生串流監控事件。

參數
opTimeout long:單一作業嘗試的等待時間上限 (毫秒)

idleOutputTimeout long:輸出串流的輸出內容最長 (以毫秒為單位)

pollInterval long:嘗試執行兩次作業時,等待的初始時間

maxTime long:嘗試執行作業的總時間約略值

runnable IRunUtil.IRunnableResult:要執行的 IRunUtil.IRunnableResult

傳回
boolean 如果作業在 maxTime 到期前成功完成,則為 true

執行時間

public abstract CommandStatus runTimed (long timeout, 
                IRunUtil.IRunnableResult runnable, 
                boolean logErrors)

封鎖並執行作業,如果作業時間超過指定時間,就會取消作業。

參數
timeout long:等待時間上限 (毫秒)

runnable IRunUtil.IRunnableResult:要執行的 IRunUtil.IRunnableResult

logErrors boolean:在例外狀況上記錄錯誤。

傳回
CommandStatus CommandStatus 作業的結果。

runTimedCmd

public abstract CommandResult runTimedCmd (long timeout, 
                OutputStream stdout, 
                OutputStream stderr, 
                String... command)

執行系統指令的輔助方法,如果執行時間超過指定時間,則會取消;如果有指定,會將輸出內容重新導向至檔案。透過這種方式提供 ERROR(/OutputStream) 時,它們會在函式結尾保持開啟。

參數
timeout long:逾時等候時間上限 (毫秒)。0 代表沒有逾時。

stdout OutputStream:要重新導向 std 輸出內容的 ERROR(/OutputStream)。可以是空值。

stderr OutputStreamERROR(/OutputStream),其中會重新導向錯誤輸出內容。可以是空值。

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmd

public abstract CommandResult runTimedCmd (long timeout, 
                String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。

參數
timeout long:等待時間上限 (毫秒)。0 代表沒有逾時。

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmd 重試

public abstract CommandResult runTimedCmdRetry (long timeout, 
                long retryInterval, 
                int attempts, 
                String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。

參數
timeout long:每次嘗試時等待的時間上限 (毫秒)

retryInterval long:每次重試指令前的等待時間

attempts int:嘗試次數上限

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmd 重試 WithOutputMonitor

public abstract CommandResult runTimedCmdRetryWithOutputMonitor (long timeout, 
                long idleOutputTimeout, 
                long retryInterval, 
                int attempts, 
                String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。一併監控活動的輸出串流,如果在指定時間未觀察到串流活動時取消,則取消串流。如果閒置輸出逾時設為零,就不會發生串流監控的情形。

參數
timeout long:每次嘗試時等待的時間上限 (毫秒)

idleOutputTimeout long:輸出串流的輸出內容最長 (以毫秒為單位)

retryInterval long:每次重試指令前的等待時間

attempts int:嘗試次數上限

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmdSilently

public abstract CommandResult runTimedCmdSilently (long timeout, 
                String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。與 runTimedCmd(long, String) 類似,但不會記錄例外狀況上的任何錯誤。

參數
timeout long:等待時間上限 (毫秒)

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmdSilently 重試

public abstract CommandResult runTimedCmdSilentlyRetry (long timeout, 
                long retryInterval, 
                int attempts, 
                String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。與 runTimedCmdRetry(long, long, int, String[]) 類似,但不會記錄例外狀況上的任何錯誤。

參數
timeout long:等待時間上限 (毫秒)

retryInterval long:每次重試指令前的等待時間

attempts int:嘗試次數上限

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmdWithInput

public abstract CommandResult runTimedCmdWithInput (long timeout, 
                String input, 
                File stdoutFile, 
                File stderrFile, 
                String... command)

執行系統指令的輔助方法,如果執行時間超過指定時間,則會取消;如果有指定,會將輸出內容重新導向至檔案。

參數
timeout long:逾時等候時間上限 (毫秒)。0 代表沒有逾時。

input String:要傳遞給處理的 stdin 輸入內容

stdoutFile File:要重新導向 std 輸出內容的 ERROR(/File)。可以是空值。

stderrFile FileERROR(/File),其中會重新導向錯誤輸出內容。可以是空值。

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmdWithInput

public abstract CommandResult runTimedCmdWithInput (long timeout, 
                String input, 
                String... command)

輔助方法可執行需要 stdin 輸入的系統指令,並在所需時間超過指定時間時取消。

參數
timeout long:等待時間上限 (毫秒)

input String:要傳遞給處理的 stdin 輸入內容

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmdWithInput

public abstract CommandResult runTimedCmdWithInput (long timeout, 
                String input, 
                 command)

輔助方法可執行需要 stdin 輸入的系統指令,並在所需時間超過指定時間時取消。

參數
timeout long:等待時間上限 (毫秒)

input String:要傳遞給處理的 stdin 輸入內容

command ERROR(/List),包含系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmdWithInputRedirect

public abstract CommandResult runTimedCmdWithInputRedirect (long timeout, 
                File inputRedirect, 
                String... command)

輔助方法可執行需要從檔案重新導向 Stdin 的系統指令,並在所需時間超過指定時間時取消。

參數
timeout long:等待時間上限 (毫秒)

inputRedirect File:使用 ProcessBuilder.redirectInput() 重新導向至標準輸入的 ERROR(/File)。如果值為空值,系統不會重新導向 stdin。

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmdWithOutputMonitor

public abstract CommandResult runTimedCmdWithOutputMonitor (long timeout, 
                long idleOutputTimeout, 
                OutputStream stdout, 
                OutputStream stderr, 
                String... command)

執行系統指令的輔助方法,如果執行時間超過指定時間,則會取消;如果有指定,會將輸出內容重新導向至檔案。透過這種方式提供 ERROR(/OutputStream) 時,它們會在函式結尾保持開啟。

參數
timeout long:逾時等候時間上限 (毫秒)。0 代表沒有逾時。

idleOutputTimeout long:輸出串流的輸出內容最長 (以毫秒為單位)

stdout OutputStream:要重新導向 std 輸出內容的 ERROR(/OutputStream)。可以是空值。

stderr OutputStreamERROR(/OutputStream),其中會重新導向錯誤輸出內容。可以是空值。

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmdWithOutputMonitor

public abstract CommandResult runTimedCmdWithOutputMonitor (long timeout, 
                long idleOutputTimeout, 
                String... command)

輔助方法執行系統指令,並在所需時間超過指定時間時取消。一併監控活動的輸出串流,如果在指定時間未觀察到串流活動時取消,則取消串流。如果閒置輸出逾時設為零,就不會發生串流監控的情形。

參數
timeout long:等待時間上限 (毫秒)。0 代表沒有逾時。

idleOutputTimeout long:輸出串流的輸出內容最長 (以毫秒為單位)

command String:指定的系統指令和 exec 的選用引數

傳回
CommandResult 含有執行指令執行結果的 CommandResult

runTimedCmdWithOutputMonitor

public abstract CommandResult runTimedCmdWithOutputMonitor (long timeout, 
                long idleOutputTimeout, 
                OutputStream stdout, 
                OutputStream stderr, 
                ICacheClient cacheClient, 
                String... command)

透過快取執行系統指令的輔助方法。

如果指定 cacheClient,系統就會啟用快取。如果有可用的快取,系統會傳回快取結果。否則,系統會使用 runTimedCmdWithOutputMonitor(long, long, OutputStream, OutputStream, String) 執行指令,並上傳結果以供快取。

參數
timeout long:逾時等候時間上限 (毫秒)。0 代表沒有逾時。

idleOutputTimeout long:輸出串流的輸出內容最長 (以毫秒為單位)。

stdout OutputStream:要重新導向 std 輸出內容的 ERROR(/OutputStream)。可以是空值。

stderr OutputStreamERROR(/OutputStream),其中會重新導向錯誤輸出內容。可以是空值。

cacheClient ICacheClient:用於處理快取的 ICacheClient 例項。

command String:指定的系統指令和 exec 的選用引數。

傳回
CommandResult 含有指令執行結果的 CommandResult

runTimed 重試

public abstract boolean runTimedRetry (long opTimeout, 
                long pollInterval, 
                int attempts, 
                IRunUtil.IRunnableResult runnable)

多次封鎖並執行一項作業,直到成功為止。

參數
opTimeout long:嘗試一次作業後等待的時間上限 (毫秒)

pollInterval long:每次重試指令前的等待時間

attempts int:嘗試次數上限

runnable IRunUtil.IRunnableResult:要執行的 IRunUtil.IRunnableResult

傳回
boolean 如果作業在嘗試前已順利完成,則為 true

runTimed 重試 WithOutputMonitor

public abstract boolean runTimedRetryWithOutputMonitor (long opTimeout, 
                long idleOutputTimeout, 
                long pollInterval, 
                int attempts, 
                IRunUtil.IRunnableResult runnable)

多次封鎖並執行一項作業,直到成功為止。還會監控活動的輸出串流,如果在指定時間未觀察到串流活動時取消,則取消串流。如果閒置輸出逾時設為零,就不會發生串流監控事件。

參數
opTimeout long:嘗試一次作業後等待的時間上限 (毫秒)

idleOutputTimeout long:輸出串流的輸出內容最長 (以毫秒為單位)

pollInterval long:每次重試指令前的等待時間

attempts int:嘗試次數上限

runnable IRunUtil.IRunnableResult:要執行的 IRunUtil.IRunnableResult

傳回
boolean 如果作業在嘗試前已順利完成,則為 true

runTimedWithOutputMonitor

public abstract CommandStatus runTimedWithOutputMonitor (long timeout, 
                long idleOutputTimeout, 
                IRunUtil.IRunnableResult runnable, 
                boolean logErrors)

封鎖並執行作業,如果作業時間超過指定時間,就會取消作業。也會監控活動的輸出串流,如果在指定時間未觀察到串流活動時取消,則取消串流。如果閒置輸出逾時設為零,就不會發生串流監控事件。

參數
timeout long:等待時間上限 (毫秒)

idleOutputTimeout long:輸出串流的輸出內容最長 (以毫秒為單位)

runnable IRunUtil.IRunnableResult:要執行的 IRunUtil.IRunnableResult

logErrors boolean:在例外狀況上記錄錯誤。

傳回
CommandStatus CommandStatus 作業的結果。

setEnvVariable

public abstract void setEnvVariable (String key, 
                String value)

設定執行系統指令時要使用的環境變數。

參數
key String:變數名稱

value String:變數值

setEnvVariablePriority

public abstract void setEnvVariablePriority (IRunUtil.EnvPriority priority)

決定是否建立程序時,取消設定環境變數的優先順序是否高於設定值。 取消設定的優先順序較高,亦即在嘗試設定名稱相同的變數時,不會發生此情況,因為系統會不設定該變數。 無法用於預設 IRunUtil 執行個體,

參數
priority IRunUtil.EnvPriority

setInterruptibleInFuture

public abstract void setInterruptibleInFuture (Thread thread, 
                long timeMs)

設為等待一段時間後可中斷。ERROR(/CommandScheduler#shutdownHard())

參數
thread Thread:要中斷的執行緒。

timeMs long:設定中斷前的等待時間。

setLinuxInterruptProcess

public abstract void setLinuxInterruptProcess (boolean interrupt)

允許在達到逾時時,在透過 #runTimed 方法執行的程序中使用 Linux「kill」中斷。 無法用於預設 IRunUtil 執行個體,

參數
interrupt boolean

setRedirectStderrToStdout

public abstract void setRedirectStderrToStdout (boolean redirect)

設定標準錯誤串流,在執行系統指令時重新導向至標準輸出串流。初始值為 false。

參數
redirect boolean:是否要重新導向的新值

setWorkingDir

public abstract void setWorkingDir (File dir)

設定系統指令的工作目錄。

參數
dir File:工作目錄

舒眠

public abstract void sleep (long time)

輔助方法:在指定時間休眠,忽略任何例外狀況。

參數
time long:休眠毫秒。系統會忽略小於或等於 0 的值

未設定這項政策

public abstract void unsetEnvVariable (String key)

取消設定環境變數,如此一來,系統指令就會在沒有這個環境變數的情況下執行。

參數
key String:變數名稱