您的位置:首页 > 编程语言 > VB

BAT 调用 VBS 通过curl 检查FTP中的文件日期

2010-12-16 16:35 591 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐