2015-09-07 69 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