Process (gb.util)
自从 3.15
This class is used for managing processes launched by the EXEC or SHELL instructions.
The
gb.util
component overrides it to allow to detect prompts emitted by the process on its standard output, and answer them accordingly, through the
Expect method and the
Prompt event.
Inherited constants
Inherited static properties
Inherited properties
方法
Expect
|
Tell which answer must be sent when a specific prompt is emitted by the process on its standard input.
|
Inherited methods
事件
Prompt
|
This event is raised when a prompt specified by the Expect method has been detected on the standard output of the process.
|
Inherited events
Example
Here is how to easily pilot the
scp
utility with the
Expect method:
Dim hProcess As Process
Dim sPassword As String = "BigSecret"
hProcess = Shell "scp /all/that/stuff/* login@server:~/here" For Input Output As "Process"
' Handle the message emitted when the server is unknown
hProcess.Expect("(yes/no*)?", "yes")
' Any emitted string ending with a colon is supposed to be the password prompt
hProcess.Expect(":", sPassword)
' Wait for the process to terminate
hProcess.Wait