Question : Problem getting last line of a log file on remote computer

Hi, The problem I´m having is that the follow scripts runs fine locally but has 2 very critical flaws. In first place if the folder where the scripts check for the .log file does not exists, the scripts enters n some kind of loop and never finishes. The other flaw is, if the server where you ran the script is not the localhost, the scripts enters in a loop and never gets the last line of the .log file.

here is the code i wrote for the task

In the first part the script looks for the name of the .log file inside the folder
On the second part of the script it tries to bring the last line of the log file.

Thank you in advance for your help.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
'first part
On error resume next
strComputer="AHAUKC-S3004"
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colFileList = objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_Directory.Name='C:\INSTALL\IBMSNMP_001'} Where " & "ResultClass = CIM_DataFile")

For Each objFile In colFileList
txt= objFile.name    
tmp1 = (Right(txt,3))
if (tmp1="log") then
tmp2=txt
else 
end if
Next
Const ForReading = 1
Const ForWriting = 2
Const TriStateUseDefault = -2
strFile = tmp2
wscript.echo tmp2



'second part
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strFile)
intSize = objFile.Size
Set objStream = objFile.OpenAsTextStream(ForReading, TriStateUseDefault)
If intSize > 1024 Then
    objStream.Skip(intSize - 512)
End If
Do Until objStream.AtEndOfStream
 strNextLine = objStream.ReadLine
If Trim(strNextLine) <> "" Then
    strLine = strNextLine
End If
Loop
objStream.Close
wscript.echo strLine

Answer : Problem getting last line of a log file on remote computer

http://www.pgpi.org/doc/pgpintro/

>>Anyone with a copy of your public key can then encrypt information that only you can read. Even people you have never met.

It is computationally infeasible to deduce the private key from the public key. Anyone who has a public key can encrypt information but cannot decrypt it.<<
Random Solutions  
 
programming4us programming4us