Home > Software engineering >  Secure the CRT VBS script out of the question, the log can only save the last device check in the in
Secure the CRT VBS script out of the question, the log can only save the last device check in the in

Time:10-23

The problem is, I log on multiple devices, but always in the log file shows the last device to check the information, before the equipment information should be no cover off, in CRT chose appended to the log file is not overwrite the log file (default), do not know what is going on, have the warrior know, script is as follows:
# $language="VBScript"
# $interface="1.0"

Sub Main

IpArray=ReadToArray (" IP. TXT ")
For I=0 To Ubound (IpArray) - 1
Concmd="/Telnet" + "" + IpArray (I)
CRT. Session. Connect (Concmd)
CRT. Sleep 900
CRT. Screen. Send "root" & amp; VbCR
CRT. Sleep 900
CRT. Screen. Send "admin" & amp; VbCR
CRT. Sleep 1000
CRT. Screen. Send "enable" & amp; VbCR
CRT. Sleep 900
CRT. Screen. Send "config" & amp; VbCR
CRT. Sleep 900
CRT. Session. LogFileName="c: \ a.t xt"
CRT. The session. The Log true
CRT. Sleep 900

CRT. Screen. Send "display MAC - address all" & amp; VbCR
CRT. Screen. Send "" & amp; VbCR
Do the while (CRT) Screen) WaitForString (" -- More ", 2) & lt;> False)
CRT. Screen. Send ""

Loop
CRT. The session. The Log false

CRT. Session. Disconnect
Next

End Sub

The Function ReadToArray (filespec)
Const ForReading=1
Dim fso, theFile, I, RetString
Dim retArray ()
The Set of fso=CreateObject (" Scripting. FileSystemObject ")
IF fso. FileExists (filespec) THEN
Set theFile=fso. OpenTextFile (filespec ForReading, false, false)
I=0
The Do While theFile. AtEndOfStream & lt;> True
RetString=Trim (theFile. ReadLine)
IF IsNull (RetString) & lt;> True THEN
ReDim Preserve retArray (I + 1)
RetArray (I)=RetString
I=I + 1
END the IF
Loop
TheFile. Close
ReadToArray=retArray
The ELSE
ReadToArray=Null
MsgBox "configuration files without IP address" + filespec
CRT. The session. The Log false
END the IF
End the Function

CodePudding user response:

Nobody ah,,,, khan,

CodePudding user response:

I don't know also appear similar situation and CRT version is not same
  • Related