Changeset 142 for trunk/SRC/ToBeReviewed/LECTURE/read_ftp.pro
- Timestamp:
- 07/21/06 14:47:49 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/LECTURE/read_ftp.pro
r134 r142 1 2 pro ftp_post, u, cmd, res, out=out, count=count 3 compile_opt idl2 4 if (cmd ne '') then begin 5 printf, u, cmd, format='(a)' 6 ; 7 ; comment out the following line to disable debug info 8 print, '>'+cmd 9 endif 10 if (size(out,/type) eq 0) then out='2?? *' 11 catch, err 12 if (err ne 0) then return 13 line='' 14 count=0 15 while arg_present(res) do begin 16 readf, u, line 17 if count eq 0 then res=line else res=[res,line] 18 count=count+1 19 ; 20 ; comment out the following line to disable debug info 21 print, '<'+line 22 if strmatch(line,out) then break 23 endwhile 24 end 25 26 pro ftp_parse_pasv, text, host, port 27 t=strtrim(text,2) 28 ind=where(strcmp(t,'227',3)) 29 i=ind[0] 30 if (i ne -1) then begin 31 sub=stregex(t[i],'\([0-9,]*\)',/extract) 32 p=strsplit(strmid(sub,1,strlen(sub)-2),',',/extract) 33 p=strtrim(p,2) 34 host=p[0]+'.'+p[1]+'.'+p[2]+'.'+p[3] 35 port=256*long(p[4])+long(p[5]) 36 endif 37 end 1 38 ;+ 2 ; READ_FTP3 39 ; 4 40 ; Syntax: … … 6 42 ; [,USER=string] [,PASS=string] [,/PTR] 7 43 ; 8 ; Arguments 9 ; remote_host - Name of the remote host (ftp server) that you want 10 ; to connect to, or a complete ftp location such as for example: 11 ; ftp://ftp.rsinc.com/pub/gzip/README.GZIP 44 ; @param DIR 45 ; Remote directory where the files reside on the ftp server 12 46 ; 13 ; directory - Remote directory where the files reside on the ftp14 ; server47 ; @param FILES 48 ; A single filename or an array of filenames to be retrieved. 15 49 ; 16 ; files - A single filename or an array of filenames to be 17 ; retrieved. 50 ; @keyword FILE 51 ; Set this keyword to make a local copy of the file to be 52 ; transferred. The local file will have the same name as the 53 ; remote file and will be placed in the current working 54 ; directory. 18 55 ; 19 ; Keywords 20 ; FILE - Set this keyword to make a local copy of the file to be 21 ; transferred. The local file will have the same name as the 22 ; remote file and will be placed in the current working 23 ; directory. 56 ; @keyword DATA 57 ; Set this to a named variable that will contain either a 58 ; byte array or an array of pointers to byte arrays with the 59 ; transferred data. If there is more than one file, an array 60 ; of pointers is returned, one for each file. 61 ; Note that when downloading large files using /FILE 62 ; instead will require much less memory since the entire file 63 ; is not stored in a variable in that case. 24 64 ; 25 ; DATA - Set this to a named variable that will contain either a 26 ; byte array or an array of pointers to byte arrays with the 27 ; transferred data. If there is more than one file, an array 28 ; of pointers is returned, one for each file. 29 ; Note that when downloading large files using /FILE 30 ; instead will require much less memory since the entire file 31 ; is not stored in a variable in that case. 65 ; @keyword PTR 66 ; Set this keyword to return an array of pointers 67 ; even when there is only one file. 32 68 ; 33 ; PTR - Set this keyword to return an array of pointers34 ; even when there is only one file.69 ; @keyword USER 70 ; Specify user name to connect to server with. Default is: anonymous. 35 71 ; 36 ; USER - Specify user name to connect to server with. Default is:37 ; anonymous.72 ; @keyword PASS 73 ; Specify password to use when connecting. Default is: test@test.com. 38 74 ; 39 ; PASS - Specify password to use when connecting. Default is: 40 ; test@test.com. 41 ; 42 ; Examples of use. 75 ; @examples 43 76 ; 1) Retrieve and print the contents of ftp://ftp.rsinc.com/pub/gzip/README.GZIP: 44 77 ; IDL> READ_FTP, 'ftp://ftp.rsinc.com/pub/gzip/README.GZIP', DATA=data … … 80 113 ; /COMPRESSED keyword. 81 114 ; 115 ; @history 116 ; 117 ; @version 118 ; $Id$ 119 ; 120 ; @todo seb: que fait-on de "syntax" au debut du header? 121 ; 82 122 ;- 83 pro ftp_post, u, cmd, res, out=out, count=count84 compile_opt idl285 if (cmd ne '') then begin86 printf, u, cmd, format='(a)'87 ;88 ; comment out the following line to disable debug info89 print, '>'+cmd90 endif91 if (size(out,/type) eq 0) then out='2?? *'92 catch, err93 if (err ne 0) then return94 line=''95 count=096 while arg_present(res) do begin97 readf, u, line98 if count eq 0 then res=line else res=[res,line]99 count=count+1100 ;101 ; comment out the following line to disable debug info102 print, '<'+line103 if strmatch(line,out) then break104 endwhile105 end106 107 pro ftp_parse_pasv, text, host, port108 t=strtrim(text,2)109 ind=where(strcmp(t,'227',3))110 i=ind[0]111 if (i ne -1) then begin112 sub=stregex(t[i],'\([0-9,]*\)',/extract)113 p=strsplit(strmid(sub,1,strlen(sub)-2),',',/extract)114 p=strtrim(p,2)115 host=p[0]+'.'+p[1]+'.'+p[2]+'.'+p[3]116 port=256*long(p[4])+long(p[5])117 endif118 end119 120 123 pro read_ftp, site, files, dir, port, data=data, file=file, user=user, $ 121 124 pass=pass, ptr=ptr
Note: See TracChangeset
for help on using the changeset viewer.