Ignore:
Timestamp:
07/21/06 14:47:49 (18 years ago)
Author:
navarro
Message:

english and nicer header (2a)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/ToBeReviewed/LECTURE/read_ftp.pro

    r134 r142  
     1 
     2pro 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 
     24end 
     25 
     26pro 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 
     37end 
    138;+ 
    2 ; READ_FTP 
    339; 
    440; Syntax: 
     
    642;              [,USER=string] [,PASS=string] [,/PTR] 
    743; 
    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 
    1246; 
    13 ;   directory - Remote directory where the files reside on the ftp 
    14 ;               server 
     47; @param FILES 
     48; A single filename or an array of filenames to be retrieved. 
    1549; 
    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. 
    1855; 
    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. 
    2464; 
    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. 
    3268; 
    33 ;   PTR  - Set this keyword to return an array of pointers 
    34 ;          even when there is only one file. 
     69; @keyword USER 
     70; Specify user name to connect to server with.  Default is: anonymous. 
    3571; 
    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. 
    3874; 
    39 ;   PASS - Specify password to use when connecting.  Default is: 
    40 ;          test@test.com. 
    41 ; 
    42 ; Examples of use. 
     75; @examples 
    4376; 1) Retrieve and print the contents of ftp://ftp.rsinc.com/pub/gzip/README.GZIP: 
    4477;   IDL> READ_FTP, 'ftp://ftp.rsinc.com/pub/gzip/README.GZIP', DATA=data 
     
    80113;   /COMPRESSED keyword. 
    81114; 
     115; @history 
     116; 
     117; @version 
     118; $Id$ 
     119; 
     120; @todo seb: que fait-on de "syntax" au debut du header? 
     121;  
    82122;- 
    83 pro ftp_post, u, cmd, res, out=out, count=count 
    84   compile_opt idl2 
    85   if (cmd ne '') then begin 
    86     printf, u, cmd, format='(a)' 
    87 ; 
    88 ; comment out the following line to disable debug info 
    89     print, '>'+cmd 
    90   endif 
    91   if (size(out,/type) eq 0) then out='2?? *' 
    92   catch, err 
    93   if (err ne 0) then return 
    94   line='' 
    95   count=0 
    96   while arg_present(res) do begin 
    97     readf, u, line 
    98     if count eq 0 then res=line else res=[res,line] 
    99     count=count+1 
    100 ; 
    101 ; comment out the following line to disable debug info 
    102     print, '<'+line 
    103     if strmatch(line,out) then break 
    104   endwhile 
    105 end 
    106  
    107 pro ftp_parse_pasv, text, host, port 
    108   t=strtrim(text,2) 
    109   ind=where(strcmp(t,'227',3)) 
    110   i=ind[0] 
    111   if (i ne -1) then begin 
    112     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   endif 
    118 end 
    119  
    120123pro read_ftp, site, files, dir, port, data=data, file=file, user=user, $ 
    121124              pass=pass, ptr=ptr 
Note: See TracChangeset for help on using the changeset viewer.