VBS调用curl 检查FTP中的文件日期,传入一个日期参数,然后ftp某个目录中的所有文件和这个日期进行比较.返回大于传入日期参数的个数.
Set objArgs = WScript.Arguments
strTmp=now
If objArgs.Count>0 Then
strTmp= objArgs(0)
End If
If Len(strTmp)=0 or objArgs.Count=0 Then
strTmp=trim(inputbox("Entry Date","Date",strTmp ))
End If
If Len(strTmp)>0 Then
strTmp=CDate(left(CDate(strTmp),11))
'msgbox strTmp
Set objShell = CreateObject("Wscript.Shell")
SET A = objShell.exec("curl.exe ""ftp://xxxxxxx/"" -X ""list -al"" -u username:password").stdout
b = A.readall
tmpLine= split(b,vbcrlf)
iFileCount=0
for i=0 to UBound(tmpLine)
'读取文件列表中的每一行
if Len(tmpLine(i))>0 And instr(tmpLine(i)," <DIR>")<=0 then
tmpstr=CDate(Trim(left(tmpLine(i),25)))
'日期比较
If tmpstr>strTmp Then
'计数
iFileCount=iFileCount+1
End If
'msgbox tmpstr
End if
Next
'返回计数值
'MsgBox iFileCount
WScript.Quit(iFileCount)
end if
下面的bat 调用
echo off
ChkFTPFile.vbs %date%
'如果ftp上的文件日期大于当天的文件总数为11
if ERRORLEVEL 11 run some commad

4146

被折叠的 条评论
为什么被折叠?



