我需要檢查某個文件是否可以在FTP服務器上下載。我一直在使用wget
的--spider選項來實現這一點,但是,這隻適用於404錯誤,FTP不使用。檢查FTP服務器上是否有文件
目前代碼(不工作):
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
如何檢查( 「蜘蛛」),看是否有文件可在FTP服務器上?我知道FTP的「404」版本是550(沒有這樣的文件或目錄)。