批处理命令检查 FTP 连接是否成功 [英] Batch command to check if FTP connection is successful

查看:49
本文介绍了批处理命令检查 FTP 连接是否成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个批处理命令来通过 FTP 发送数据.在发送实际数据之前,我需要确定 FTP 服务器是否处于活动状态/正在运行.如何在批处理命令中检查?

I am writing a batch command to send data via FTP. Before sending the actual data I need to find if the FTP server is active/running. How do I check that in batch command?

服务器在连接时响应220 server ready"消息.

The server responds with "220 server ready" message when it is connected.

推荐答案

我认为 Windows ftp.exe 没有可靠的方法.

I do not think there's a reliable way to do this with Windows ftp.exe.

无论连接成功还是之前的命令成功,它都会盲目地继续运行命令.

It blindly keeps running the commands, no matter if connection or previous commands succeeded.

它甚至不会通过退出代码报告结果.

It won't even report the result via exit code.

您所能做的就是解析 ftp.exe 输出.

All you can do is to parse the ftp.exe output.

您最好使用第 3 方 FTP 客户端.

You should better use a 3rd-party FTP client.

例如,您可以使用 WinSCP 脚本:

@echo off

winscp.com /log=ftp.log /command ^
    "open ftp://user:password@example.com/" ^
    "put c:localpathfile.txt" ^
    "exit" 

如果连接(open 命令)失败,WinSCP 获胜'不执行以下命令(put).

If connection (the open command) fails, WinSCP won't execute the following commands (the put).

另请参阅将 Windows FTP 脚本转换为 WinSCP FTP 脚本.

(我是 WinSCP 的作者)

这篇关于批处理命令检查 FTP 连接是否成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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