2015-09-07 50 views
0

當我我得到了在服務器上運行我的腳本時:預計聲明「預期聲明」運行的VBScript

我的代碼

if STATUS = "ERROR" then 
    ext = LCase(FSO.GetExtensionName(sNewestFile)) 
    ' ZIP and RAR handler 
    ' What should it do of the ext variable is zip or Rar? 
    ' it is specified in the cases. 
    Select Case ext 
      Case "log", "txt" 
       'Runs the tail.exe file to get the last 10 lines of text in the [sNewestFile] and insert them to the log file. 
       'This will only be done IF there is a status = "ERROR" 
       errorStr = WScript.CreateObject("WScript.Shell").Exec(_ "tail -n 10 """ & sNewestFile & """" _).StdOut.ReadAll 
       objLogFile.writeline "" & vbCrLf 
       objLogFile.writeline "Error Message Start" & vbCrLf 
       objLogFile.writeline "" & errorStr & vbCrLf 
       objLogFile.writeline "Error Message End" 
      Case "zip" 
       objLogFile.writeline "" & vbCrLf 
       objLogFile.writeline "The Date of the ZIP file is to old" & vbCrLf 
      Case "rar" 
       objLogFile.writeline "" & vbCrLf 
       objLogFile.writeline "The Date of the RAR file is to old" & vbCrLf 
    End Select 'Ends the Select Case ext 
End If 

的事情是,我不斷收到somekind的錯誤的第一它是無效字符我解決了這個問題,通過做一個探測器如果語句。現在它的一個預期聲明

我只是不知道該怎麼弄出來,它出錯了?

我用於引用如下:

+0

如果select語句中沒有'Case Else',這個錯誤會發生嗎? – Jesper

回答

1

Appearently的解決方案是使用:

errorStr = WScript.CreateObject("WScript.Shell").Exec(_ 
     "tail -n 10 """ & sNewestFile & """" _ 
    ).StdOut.ReadAll 

取而代之的是1線:

errorStr = WScript.CreateObject("WScript.Shell").Exec(_ "tail -n 10 """ & sNewestFile & """" _).StdOut.ReadAll 

爲什麼是這樣,我要的線索。

+2

'_'向分析器指示該行已被分割並且代碼在下一行繼續。如果您想要將所有代碼放在一行中,請刪除下劃線。 –

+0

啊好吧,謝謝:) – Jesper