Try this. I've written it on a Win95 box, but the telnet client for NT4 should be the same.
This script will record a log session. At the moment I just display it using notepad, but of course you can read the log file in and check it automatically.
If you are using the console telnet rather than the GUI version, then of course it won't work
code:
BREAK ON
$sLogFile=%TEMP%+"\telnet.log"
Function udfSend($sTextToSend,Optional $iSleep)
If SetFocus("Telnet")
"Cannot set focus!" ?
"Reason: @ERROR @SERROR"
Quit @ERROR
EndIf
If SendKeys($sTextToSend)
"Cannot send data!"
"Reason: @ERROR @SERROR"
Quit @ERROR
EndIf
If Val($iSleep) Sleep Val($iSleep) EndIf
EndFunction
Function udfConfigServer($sServer)
RUN '%comspec% /c start telnet $sServer'
SLEEP 5
; Start logging...
udfSend("~TL"+$sLogFile+@CRLF)
; Wake up session...
udfSend(@CRLF,1)
udfSend(@CRLF,1)
; Send configuration data...
udfSend("hostname: MOEP" + @CRLF,1)
; Close client end...
udfSend("quit" + @CRLF,1)
; Shut down logging...
udfSend("~TS")
; Close telnet application...
udfSend("~{F4}")
; Display results:
Shell "%COMSPEC% /C notepad.exe " + $sLogFile
EndFunction
While "True"
"Enter server name or null to exit: " GetS $sServer
If $sServer = "" Exit 0 EndIf
udfConfigServer($sServer)
Loop