Hi,
Has anybody evercome across the above error (Microsoft VBScript runtime error: Input past end of file) and managed to resolve it?
My code below is reading from FILE A, does an nslookup on a computer in the file, pipes the output to FILE B, which is then closed and then reads FILE B and pipes the contents to FILE C (as the final result text).
After each iteration of FILE A, File B is deleted and then re-created, ready to recieve the next set of data from the nslookup. In other words, FILE B at anytime should only contain a single result for the current computer that has been read from FILE A.
The problem is that things work for the first iteration, but then the script falls over with the error: "Microsoft VBScript runtime error: Input past end of file". So I normally get a suitable result for the first computer in the list, but then nothing for the remaining computers in the list.
My script is as follows:
Set objArgs=WScript.Arguments
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
i = 0
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(objArgs(0), ForReading)
Set objShell = WScript.CreateObject("WScript.Shell")
Set objResults = objFSO.OpenTextFile("C:\Scripts\result.txt", 8)
Do While objTextFile.AtEndOfStream <> True
strComputer = objTextFile.Readline
objDictionary.Add i, strComputer
i = i + 1
Loop
For Each objItem In objDictionary
StrComputer = objDictionary.Item(objItem)
WScript.Echo "Checking.. " & strComputer
Call FileDel
Call NLookup
Call Reader
Next
Sub FileDel
If objFSO.FileExists("C:\Scripts\Logger.txt") Then
objFSO.DeleteFile("C:\Scripts\Logger.txt")
Set objFile = objFSO.CreateTextFile("C:\Scripts\Logger.txt")
Else
Set objFile = objFSO.CreateTextFile("C:\Scripts\Logger.txt")
End If
End Sub
Function NLookup
Set objExecObject=objShell.Exec("nslookup" & " " & strComputer)
Set objFile = objFSO.OpenTextFile("C:\Scripts\Logger.txt", ForWriting)
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadLine()
objFile.WriteLine strText
WScript.Echo strText
Loop
objFile.Close
End Function
Sub Reader
Set objReadLogger = objFSO.OpenTextFile("C:\Scripts\Logger.txt", ForReading)
Do While objReadLogger.AtEndOfStream <> True
objReadLogger.SkipLine
objReadLogger.SkipLine
objReadLogger.SkipLine
objReadLogger.SkipLine
strLine = objReadLogger.ReadLine
objResults.WriteLine strComputer & ", " & strLine
Loop
'objReadLogger = Nothing
objReadLogger.Close
End Sub
Any help would be great.
Has anybody evercome across the above error (Microsoft VBScript runtime error: Input past end of file) and managed to resolve it?
My code below is reading from FILE A, does an nslookup on a computer in the file, pipes the output to FILE B, which is then closed and then reads FILE B and pipes the contents to FILE C (as the final result text).
After each iteration of FILE A, File B is deleted and then re-created, ready to recieve the next set of data from the nslookup. In other words, FILE B at anytime should only contain a single result for the current computer that has been read from FILE A.
The problem is that things work for the first iteration, but then the script falls over with the error: "Microsoft VBScript runtime error: Input past end of file". So I normally get a suitable result for the first computer in the list, but then nothing for the remaining computers in the list.
My script is as follows:
Set objArgs=WScript.Arguments
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
i = 0
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(objArgs(0), ForReading)
Set objShell = WScript.CreateObject("WScript.Shell")
Set objResults = objFSO.OpenTextFile("C:\Scripts\result.txt", 8)
Do While objTextFile.AtEndOfStream <> True
strComputer = objTextFile.Readline
objDictionary.Add i, strComputer
i = i + 1
Loop
For Each objItem In objDictionary
StrComputer = objDictionary.Item(objItem)
WScript.Echo "Checking.. " & strComputer
Call FileDel
Call NLookup
Call Reader
Next
Sub FileDel
If objFSO.FileExists("C:\Scripts\Logger.txt") Then
objFSO.DeleteFile("C:\Scripts\Logger.txt")
Set objFile = objFSO.CreateTextFile("C:\Scripts\Logger.txt")
Else
Set objFile = objFSO.CreateTextFile("C:\Scripts\Logger.txt")
End If
End Sub
Function NLookup
Set objExecObject=objShell.Exec("nslookup" & " " & strComputer)
Set objFile = objFSO.OpenTextFile("C:\Scripts\Logger.txt", ForWriting)
Do While Not objExecObject.StdOut.AtEndOfStream
strText = objExecObject.StdOut.ReadLine()
objFile.WriteLine strText
WScript.Echo strText
Loop
objFile.Close
End Function
Sub Reader
Set objReadLogger = objFSO.OpenTextFile("C:\Scripts\Logger.txt", ForReading)
Do While objReadLogger.AtEndOfStream <> True
objReadLogger.SkipLine
objReadLogger.SkipLine
objReadLogger.SkipLine
objReadLogger.SkipLine
strLine = objReadLogger.ReadLine
objResults.WriteLine strComputer & ", " & strLine
Loop
'objReadLogger = Nothing
objReadLogger.Close
End Sub
Any help would be great.