【发布时间】:2017-04-13 09:55:01
【问题描述】:
我需要检查某个文件是否可以在 FTP 服务器上下载。我一直在使用wget 的 --spider 选项通过 HTTP 实现此目的,但这仅适用于 FTP 不使用的 404 错误。
当前代码(不工作):
file1="12345.tar"
abc1="http://some.website/data/${file1}"
if wget --no-cache --spider --user=username --password='password' ${abc1} >/dev/null 2>&1; then
echo "File ${abc1} exists. Let's get it!"
bash run.sh
else
echo "File ${abc1} doesn't exist. Exiting script..."
exit 0
fi
如何检查(“spider”)以查看 FTP 服务器上的文件是否可用?我知道 FTP 的“404”版本是 550(没有这样的文件或目录)。
【问题讨论】: