home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / wps / editor / epmtools / epmsmp / ftpload.e < prev    next >
Text File  |  1992-08-26  |  3KB  |  104 lines

  1. ; See comments in FTPSAVE.E
  2. ;
  3. ;                Larry Margolis
  4.  
  5. tryinclude 'MYCNF.E'  -- User can point to FTP.EXE here.  Required if not in path.
  6.  
  7. const
  8. compile if not defined(ftp_pgm)
  9.    ftp_pgm= 'FTP.EXE'                -- location of the FTP.EXE program - in path?
  10. compile endif
  11.  
  12. defmain
  13.    universal vtemp_path
  14. ;; parse arg filename machname user pass '/' opts
  15.    parse arg filename rest
  16.    parse value rest with stuff '/' opts
  17.    parse value stuff with machname user pass
  18.    opts = upcase(opts)
  19.    mode = ''; cd = ''
  20.    do while opts <> ''
  21.       parse value opts with opt rest '/' opts
  22.       if opt='A' | opt='ASC' | opt='ASCII' then
  23.          mode = 'ascii'
  24.       elseif opt='B' | opt='BIN' | opt='BINARY' then
  25.          mode = 'binary'
  26.       elseif opt='CD' then cd = rest
  27.       else
  28.          sayerror 'Unknown option 'opt' ignored.'
  29.       endif
  30.    enddo
  31.    if not mode then
  32.       ext = filetype(filename)
  33.       if substr(ext,max(length(ext)-2,1)) = 'BIN' |
  34.          pos(' 'substr(ext,1,3),' BIN RAM ARC EXE LIB DLL COM OBJ SYS FLS ICO TBH IMG GVX ZIP')
  35.       then
  36.          mode = 'binary'
  37.       else
  38.          mode = 'ascii'
  39.       endif
  40.    endif
  41.    if user = '' then
  42.       sayerror 'Required parm missing: FTPLOAD fname mach_name user [pass] [/a | /b] [/cd dir]'
  43.       return
  44.    endif
  45.    if pass = '' then
  46.       pass = entrybox('Enter password for 'user' on 'machname)
  47.    endif
  48.    if pass = '' then
  49.       sayerror 'No password entered.  Command halted.'
  50.       return
  51.    endif
  52. compile if EVERSION < 5
  53.    wind='tmp'
  54. compile else
  55.    wind=substr(ltoa(gethwnd(5),16),1,4)
  56. compile endif
  57.    cmdfile = vtemp_path'cmds'wind'.ftp'
  58.    'xcom e /c 'cmdfile
  59.    tempfile=vtemp_path'LOAD'wind'.FTP'
  60.    replaceline 'open 'machname, 1
  61.    insertline 'user 'user pass, 2
  62.    insertline mode, 3
  63.    l = length(vTEMP_PATH)
  64.    insertline 'lcd 'substr(vtemp_path,1,L - (L>3 & substr(vTEMP_PATH,L,1)='\')), 4
  65.    if cd<>'' then
  66.       insertline 'cd 'cd, 5
  67.    endif
  68.    insertline 'get 'filename' LOAD'wind'.FTP', .last+1
  69.    'xcom save'; src = rc
  70.    'xcom quit'
  71.    if src then sayerror 'Error 'src' saving 'cmdfile'.  Command halted.'; stop; endif
  72.    sayerror 'Attempting to get 'filename' from 'machname cd' in 'mode
  73.    outfile = vtemp_path'outp'wind'.ftp'
  74.    quietshell ftp_pgm '-n <'cmdfile '>'outfile
  75.    ftp_rc = rc
  76.    call erasetemp(cmdfile)
  77.    If ftp_rc then
  78.       sayerror 'RC from 'FTP_pgm' =' ftp_rc'; outfile='outfile;
  79.       rc = ftp_rc
  80.       return
  81.    endif
  82.    'xcom e /d 'tempfile
  83.    erc = rc
  84. ;sayerror 'rc='rc '"'sayerrortext(rc)'"'
  85.    .filename = '['machname'.'user'.'cd'] 'filename
  86.    .autosave = 0
  87. compile if EVERSION >= 5
  88.    .userstring = .userstring ''pass''mode''
  89. compile endif
  90.    .autosave = 0
  91.    call erasetemp(tempfile)
  92.    sayerror 0
  93.    if erc & erc<>sayerror('Lines truncated') then
  94.       'xcom q'
  95.       'e /d 'outfile
  96.       if erc = sayerror('New file') then
  97.          sayerror 'File not gotten.  FTP messages shown below.'
  98.       else
  99.          sayerror 'Error 'erc' loading temp file 'tempfile
  100.       endif
  101.    endif
  102.    call erasetemp(outfile)
  103.  
  104.