寫了一個簡單的Linux Shell用來下載文件


#!/bin/sh
for (( i=0; i<30; i=i+1 )); do
    # 利用spider來探測請求的資源是否存在,並把請求的結果寫入到一個文件
    wget --spider --http-user=username --http-password=passwd --no-check-certificate -e "https_proxy=http://URL:port" fileURL &> spiderResult.txt
    
    # 把文件內容讀取到一個變量中
    abc="`cat /home/yxf/spiderResult.txt`"
    
    # 讀取變量的最后6個字符,如果是exists則說明要下載的文件是存在的,這種情況下可以發起文件下載請求
    okIndex=${abc:(-7):6}
    if [ "$okIndex" = "exists" ]; then
        # 文件下載
        wget -P /download/billdownload --http-user=username --http-password=passwd --no-check-certificate -e "https_proxy=http://URL:port" fileURL 
        break
    fi
    
    # 如果文件不存在,則把當前線程睡眠20分鍾
    sleep 20m
done

 

幫助到您了嗎?

打賞作者(支付寶):


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM