FTP downloading in IDL [message #80937] |
Sat, 21 July 2012 13:50 |
Jianbao
Messages: 16 Registered: December 2008
|
Junior Member |
|
|
Dear all,
I am recently interested in network programming in IDL because I want to download geomagnetic Kp indices from a NOAA FTP server. The data files are under:
ftp://ftp.ngdc.noaa.gov/STP/GEOMAGNETIC_DATA/INDICES/KP_AP
I tried both SOCKET and IDLnetURL, but didn't get much of luck in either case. The platforms I used include 1) OS X Lion + IDL 8.2 and 2) Snow Leopard + IDL 7.1/8.1.
First, for socket, I used a solution, *read_ftp*, from the IDL official website:
http://www.exelisvis.com/language/en-US/Support/HelpArticleD etail/articleid/3537.aspx?dnnprintmode=true&mid=6229& ;SkinSrc=%5BG%5DSkins%2F_default%2FNo+Skin&ContainerSrc= %5BG%5DContainers%2F_default%2FNo+Container
Here is my code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;
url = ' ftp://ftp.ngdc.noaa.gov/STP/GEOMAGNETIC_DATA/INDICES/KP_AP/2 008'
read_ftp, url, file = '2008'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;
Below between the two star lines is what happened in IDL:
************************************************************ ***********************************
IDL> url = ' ftp://ftp.ngdc.noaa.gov/STP/GEOMAGNETIC_DATA/INDICES/KP_AP/2 008'
IDL> read_ftp, url, file = '2008'
<220- ----- Notice -----
<220-
<220- This is a United States Department of Commerce computer system, which
<220- may be accessed and used only for official Government business by
<220- authorized personnel. Unauthorized access or use of this computer
<220- system may subject violators to criminal, civil, and/or administrative
<220- action.
<220-
<220- All information on this computer system may be intercepted, recorded,
<220- read, copied, and disclosed by and to authorized personnel for
<220- official purposes, including criminal investigations. Access or use of
<220- this computer system by any person whether authorized or unauthorized,
<220- constitutes consent to these terms.
<220-
<220- ----- Notice -----
<220-
<220- Questions/Problems should be directed to ngdc.linux-admin@noaa.gov
<220
> USER anonymous
************************************************************ **************************************
IDL became frozen after I got above output.
Second, for IDLnetURL, I used a solution described in this article:
http://www.exelisvis.com/Support/HelpArticleDetail/ArticleId /4246.aspx
Here is my code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
oUrl = OBJ_NEW('IDLnetUrl', URL_SCHEME='ftp', $
URL_HOST='ftp.ngdc.noaa.gov', $
URL_Port=21, $
URL_USERNAME='anonymous', URL_PASSWORD='', $
URL_PATH='STP/GEOMAGNETIC_DATA/INDICES/KP_AP/2008')
downloadLoc = oURL->Get(FILENAME='2008')
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I got this output, after I waited more than 10 minutes:
************************************************************ ***********************
% IDLNETURL::GET: CCurlException: Error: Ftp Get Request Failed. Error = select/poll error, Curl
Error Code = 27. Last Ftp Response = 250 Directory successfully changed.
************************************************************ ***********************
So, does anyone know a working solution to download a file from an FTP server, please? Your help is much appreciated!
Best regards,
JBT
|
|
|