home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / epmsmp.zip / FTPLOAD.E < prev    next >
Text File  |  1995-10-26  |  4KB  |  114 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. compile if EVERSION >= '6.01'
  47.       pass = entrybox('Enter password for 'user' on 'machname,
  48.                       '',  -- Buttons
  49.                       '',  -- Entry text
  50.                       '',  -- Cols
  51.                       250,  -- Max len
  52.                       '',  -- Return buffer
  53.                       140) -- ES_UNREADABLE + ES_AUTOSCROLL + ES_MARGIN
  54. compile else
  55.       pass = entrybox('Enter password for 'user' on 'machname)
  56. compile endif
  57.    endif
  58.    if pass = '' then
  59.       sayerror 'No password entered.  Command halted.'
  60.       return
  61.    endif
  62. compile if EVERSION < 5
  63.    wind='tmp'
  64. compile else
  65.    wind=substr(ltoa(gethwnd(5),16),1,4)
  66. compile endif
  67.    cmdfile = vtemp_path'cmds'wind'.ftp'
  68.    'xcom e /c 'cmdfile
  69.    tempfile=vtemp_path'LOAD'wind'.FTP'
  70.    replaceline 'open 'machname, 1
  71.    insertline 'user 'user pass, 2
  72.    insertline mode, 3
  73.    l = length(vTEMP_PATH)
  74.    insertline 'lcd 'substr(vtemp_path,1,L - (L>3 & substr(vTEMP_PATH,L,1)='\')), 4
  75.    if cd<>'' then
  76.       insertline 'cd 'cd, 5
  77.    endif
  78.    insertline 'get 'filename' LOAD'wind'.FTP', .last+1
  79.    'xcom save'; src = rc
  80.    'xcom quit'
  81.    if src then sayerror 'Error 'src' saving 'cmdfile'.  Command halted.'; stop; endif
  82.    sayerror 'Attempting to get 'filename' from 'machname cd' in 'mode
  83.    outfile = vtemp_path'outp'wind'.ftp'
  84.    quietshell ftp_pgm '-n <'cmdfile '>'outfile
  85.    ftp_rc = rc
  86.    call erasetemp(cmdfile)
  87.    If ftp_rc then
  88.       sayerror 'RC from 'FTP_pgm' =' ftp_rc'; outfile='outfile;
  89.       rc = ftp_rc
  90.       return
  91.    endif
  92.    'xcom e /d 'tempfile
  93.    erc = rc
  94. ;sayerror 'rc='rc '"'sayerrortext(rc)'"'
  95.    .filename = '['machname'.'user'.'cd'] 'filename
  96.    .autosave = 0
  97. compile if EVERSION >= 5
  98.    .userstring = .userstring ''pass''mode''
  99. compile endif
  100.    .autosave = 0
  101.    call erasetemp(tempfile)
  102.    sayerror 0
  103.    if erc & erc<>sayerror('Lines truncated') then
  104.       'xcom q'
  105.       'e /d 'outfile
  106.       if erc = sayerror('New file') then
  107.          sayerror 'File not gotten.  FTP messages shown below.'
  108.       else
  109.          sayerror 'Error 'erc' loading temp file 'tempfile
  110.       endif
  111.    endif
  112.    call erasetemp(outfile)
  113.  
  114.