2
我試圖處理消息時,新的IP /服務器被登錄到自動連接,這是我到目前爲止有:處理服務器驗證的正則表達式SSH讀
$read = $this->ssh->read('(Password:)|(Are you sure you want to continue connecting)', NET_SSH2_READ_REGEX);
if (preg_match('/Are you sure you want to continue connecting/',$read)) {
$this->ssh->write('yes');
$this->ssh->write("\n");
$this->ssh->read('Permanently added');
$this->ssh->write('ssh '.$this->userid.'@'.$this->testIPAddress);
$this->ssh->write("\n");
$read = $this->ssh->read('(Password:)|(Are you sure you want to continue connecting)', NET_SSH2_READ_REGEX);
} else if ($this->ssh->isTimeout()) {
$testLineHideResult = "Connection failed";
}
if ($testLineHideResult == '') {
$this->ssh->write($this->passwd);
$this->ssh->write("\n");
$this->ssh->setTimeout(25);
但我得到以下錯誤消息:
preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Unknown modifier '|'
你能幫我解決這個問題嗎?或者重寫它來讓它工作?任何的建議是有幫助:)
這似乎是 「|」在$ read變量發出這個問題。它實際上是否有助於您使用的功能? –
是的,這是造成這個問題,我需要它讀取「密碼」或「你確定你想繼續連接」。 – LeeBronwin
使用'$ this-> ssh-> read('/ Password:|是否確定要繼續連接/',NET_SSH2_READ_REGEX);' –