2016-05-14 60 views
3

我試圖下載通過內容處置發送的KML文件:從以下網站附件:wget的與內容處置打破

http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia 

使用wget,可以在命令捲曲:

wget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia 

curl -O -J -L http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia 

然而,而不是保存在文件被髮送,這樣可以節省只爲H tml內容,並在傳輸結束時卡住。終端返回是:

$wget --content-disposition http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia 
[1] 32260 
[2] 32261 
[3] 32262 
[email protected]:~$ --2016-05-13 19:37:54-- http://waterwatch.usgs.gov/index.php?m=real 
Resolving waterwatch.usgs.gov (waterwatch.usgs.gov)... 2001:49c8:0:126c::56, 137.227.242.56 
Connecting to waterwatch.usgs.gov (waterwatch.usgs.gov)|2001:49c8:0:126c::56|:80... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: unspecified [text/html] 
Saving to: ‘index.php?m=real.5’ 

    [ <=>                                     ] 41.637  174KB/s in 0,2s 

2016-05-13 19:37:55 (174 KB/s) - ‘index.php?m=real.5’ saved [41637] 

而他們得到了stuch,我需要按Ctrl + C。 當我得到的頭是

HTTP/1.1 200 OK 
Date: Sat, 14 May 2016 00:19:21 GMT 
Content-Disposition: attachment; filename="real_ia.kml" 
Keep-Alive: timeout=5, max=100 
Connection: Keep-Alive 
Transfer-Encoding: chunked 
Content-Type: application/vnd.google-earth.kml+xml 
X-Frame-Options: SAMEORIGIN 

我希望有下載的「real_ia.kml」文件。 使用curl命令給出了類似的結果。

它爲什麼會卡住並只下載HTML內容?

回答

1

&符號被解釋爲導致命令在後臺運行(到fork)的shell特殊字符。所以,你應該escape or quote他們:

curl -O -J -L 'http://waterwatch.usgs.gov/index.php?m=real&w=kml&r=us&regions=ia' 

在上面的命令,我們使用full quoting

下從輸出線意味着三個命令正在分叉背景:

[1] 32260 
[2] 32261 
[3] 32262 

在左邊的數字(在括號中)是就業數據。您可以通過輸入fg N將作業帶到前臺,其中N是作業的編號。右邊的數字是進程ID。

+0

魯斯蘭奧斯馬諾夫,你救了那一天! 現在所有的東西都用命令運行: 'curl -O -J -L http://waterwatch.usgs.gov/index.php?m = real \&w = kml \&r = us \&regions = ia' (只是在這裏發佈,以清除其他人) 非常感謝! –