Solved

VBS Expected Statement?

Posted on 2009-04-01
5
756 Views
Last Modified: 2012-05-06
I'm having an issue on line 21, 2 (Wend) with an Expected Statement

Microsoft VBScript compilation error: Expected statement

This may not have anything to do with Wend but may have something to do with incorrect statement somewhere else in the script I don't know.

Does anybody see anything obvious? What the script does is remote to a server and read the log file. If the log contains the string blahblah, it will send an email notification.

Thi sscript is very helpfull to me so if anybody can help out I would greatly appreciate it and give you 500 points :)
Const ForReading = 1

strlocalPath = "c$\corestreet\authority\logs\rtc-java-0.log"

strBadString = "No CRL available for issuer ID"

'ADD YOUR SERVER NAMES TO THIS ARRAY....

arrServers=Array("server1","server2","server3")

 

'Build the date string to look for... (ie. today's date in the format yyyy.mm.dd)

strDateLookFor = Date Part("yyyy",Date) & "." 

If Date Part("m",Date) < 10 Then strDateLookFor = strDateLookFor & "0" & Date Part("m",Date) 
 

_

	Else strDateLookFor = strDateLookFor & Date Part("m",Date)

If Date Part("d",Date) < 10 Then strDateLookFor = strDateLookFor & ".0" & 
 

Date Part("d",Date) _

	Else strDateLookFor = strDateLookFor & "." & Date Part("d",Date)

 

Set fso = CreateObject("scripting.filesystemobject")

For i = 0 To UBound(arrServers)

	Set objTxt = fso.OpenTextFile("\\" & arrServers(i) & strLocalPath,ForReading)

	While Not objTxt.AtEndOfStream

		strLine = objTxt.ReadLine

		If InStr(strLine,strDateLookFor) > 0 And InStr(strLine,strBadString) Then 
 

sendEmail arrServers(i),strDateLookFor,strBadString

	Wend

Next

 

Set fso = Nothing

Set objTxt = Nothing

 

Sub sendEmail(strServer,strDateLookFor,strBadString)

 

Set objMessage = CreateObject("CDO.Message") 

Const smtpPort = 25

Const sendUsing = 2

Const smtpServer = "yup"

objMessage.To = "yup"

objMessage.From = "yup"

objMessage.Subject = "Log Alert!"

body = "<b>A BAD entry has been found in the log file for server : " & strServer & 
 

"</b><br><br>"

body = body & "Date : " & strDateLookFor & " - " & strBadString

objMessage.HTMLBody = body

 

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendu
 

sing") = sendUsing 

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtps
 

erver") = smtpServer

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtps
 

erverport") = smtpPort 

objMessage.Configuration.Fields.Update

 

objMessage.Send

Set objMessage = Nothing

End Sub

 

Open in New Window Select All

Open in new window

0
Comment
Question by:snyderkv
  • 2
  • 2
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 24044258
you are missing a END IF before the WEND
0
 
LVL 67

Assisted Solution

by:sirbounty
sirbounty earned 250 total points
ID: 24044457
or you can run this command altogether since you don't have an else...

If InStr(strLine,strDateLookFor) > 0 And InStr(strLine,strBadString) Then sendEmail arrServers(i),strDateLookFor,strBadString
0
 

Author Comment

by:snyderkv
ID: 24044597
Thanks a ton that worked.

My last error may be too simple to create an all new thread over so if it's obvious to you guys please point it out. I will be waiting for the next couple hours.

Microsoft VBScript compilation error: Syntax error
The line below is the last line in the script that has issues.

Open In New Window Select All
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 24044609
remove line 62 altogether...it's not script code...
0
 

Author Comment

by:snyderkv
ID: 24044662
lol
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now