2013-10-03 39 views
1

Im在設置autohotkey腳本中的錯誤級別時遇到問題。在讀取循環中出現錯誤級別的尷尬

截至目前,它工作正常,除非膩子會議意外關閉。

我在通過telnet設置ip和密碼重新啓動設備之後調用sub。

基本上,我需要一個消息框彈出和返回指令,而不是崩潰

像 MSGBOX的%IP%重啓失敗 回報

還沒有能夠得到它的工作我自己,所以想我會在這裏問

Proximreboot: 
{ 
SetKeyDelay, 10, 10 
Run, C:\Program Files\PuTTY\putty.exe -load "script" telnet://%IP%, , , NewPID ; ------------run putty.exe also get a new PID 
WinWaitActive, ahk_pid %NewPID% 

Loop ;---------------------------- loop to look for password prompt in putty 
{ 
Loop, read, C:\Program Files\PuTTY\%IP%.script.log ;----------loop to read the log file 
    last_line := A_LoopReadLine 

IfInString, last_line, password 
{ 
break 
} 

} 

ControlSend, ,%PASS%{Enter},ahk_pid %NewPID%, , , 
Sleep, 1000 
ControlSend, ,reboot 30{Enter},ahk_pid %NewPID%, , , 
Sleep, 1563 
ControlSend, ,exit{Enter},ahk_pid %NewPID%, , , 
Sleep, 1000 
filedelete, C:\Program Files\PuTTY\*.script.log 
last_line := blank 
} 
return 

回答

0

我終於想通了

Loop 
{ 
Process, Exist, %NewPID% 

Loop, read, C:\Program Files\PuTTY\%IP%.script.log 
    last_line := A_LoopReadLine 

IfInString, last_line, password 
{ 
break 
} 
if !errorlevel 
{ 
    MsgBox, Reboot of %IP% Failed. 
    Return 
} 
} 

我不知道如果我更快樂,我想明白了,或者第一次測試設備超時。