要搜索的FTP文件 [英] To search for a file at FTP

查看:84
本文介绍了要搜索的FTP文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想找到如果一个文件在使用FTP存在使用FTP批处理脚本是如下,如果同时存在的文件名-else语句:

I want to find if a file exists at FTP using if-exist filename -else statement using FTP batch script which is as follows:

ftp.txt open ftp.mysite.com
ftp.txt username
ftp.txt password
ftp.txt if exist filename (echo file exists) else (echo file doesn't exist)
ftp.txt quit
ftp -s:ftp.txt

在如果同时存在线上不起作用。
是否有任何其他的方法来搜索?

the if-exist line above does not work. Is there any other way to search?

推荐答案

不要做逻辑的FTP脚本。

Don't do the logic in the FTP script.

从一个批处理文件调用ftp.txt脚本。在您ftp.txt脚本,只需做你的文件一个GET。如果该文件是存在的,它会被下载到本地目录。否则,它不会。调用FTP脚本后,检查文件是否存在使用标准的DOS批处理命令本地目录,即:

Call the ftp.txt script from a batch file. Within your ftp.txt script, just do a GET on your file. If the file is there, it'll be downloaded to the local directory. Otherwise, it won't. After calling the FTP script, check the file's existence in your local directory using standard DOS batch commands, i.e.:

@echo off

:FETCHFILE
ftp -s:ftp.txt
IF EXIST filetocheckfor.txt (
   REM the file was there, so do something
) ELSE
   echo Trying again...
   REM ping "sleep" would go here
   GOTO FETCHFILE
)

如果你想建立一个延迟到重,通过ping一个伪造的IP地址进行休眠,因为在这个职位描述:
http://www.dullsharpness.com/ 2010/06/14 /使用纯毫秒经过计时器 - -DOS /

If you want to build a delay into your retries, perform a "sleep" by pinging a bogus IP address, as described in this post: http://www.dullsharpness.com/2010/06/14/elapsed-timer-using-pure-ms-dos/

这篇关于要搜索的FTP文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆