checking wget's return value [if]

前端 未结 6 1772
离开以前
离开以前 2020-12-09 15:18

I\'m writing a script to download a bunch of files, and I want it to inform when a particular file doesn\'t exist.

r=`wget -q www.someurl.com`
if [ $r -ne 0          


        
6条回答
  •  醉话见心
    2020-12-09 15:34

    you could just

    wget ruffingthewitness.com && echo "WE GOT IT" || echo "Failure"
    
    -(~)----------------------------------------------------------(07:30 Tue Apr 27)
    risk@DockMaster [2024] --> wget ruffingthewitness.com && echo "WE GOT IT" || echo "Failure" 
    --2010-04-27 07:30:56--  http://ruffingthewitness.com/
    Resolving ruffingthewitness.com... 69.56.251.239
    Connecting to ruffingthewitness.com|69.56.251.239|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: unspecified [text/html]
    Saving to: `index.html.1'
    
        [ <=>                                                                                    ] 14,252      72.7K/s   in 0.2s    
    
    2010-04-27 07:30:58 (72.7 KB/s) - `index.html.1' saved [14252]
    
    WE GOT IT
    -(~)-----------------------------------------------------------------------------------------------------------(07:30 Tue Apr 27)
    risk@DockMaster [2025] --> wget ruffingthewitness.biz && echo "WE GOT IT" || echo "Failure"
    --2010-04-27 07:31:05--  http://ruffingthewitness.biz/
    Resolving ruffingthewitness.biz... failed: Name or service not known.
    wget: unable to resolve host address `ruffingthewitness.biz'
    zsh: exit 1     wget ruffingthewitness.biz
    Failure
    -(~)-----------------------------------------------------------------------------------------------------------(07:31 Tue Apr 27)
    risk@DockMaster [2026] --> 
    

提交回复
热议问题