home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / ftpifs4.zip / recopy.cmd < prev    next >
OS/2 REXX Batch file  |  1999-03-09  |  1KB  |  47 lines

  1. /* Script you may use to ReGet File */
  2. blocksize=2048
  3. parse arg fr t bl
  4. if (t='') then
  5. do
  6.  say "RECOPY.CMD. Script for copying files (no EA support)"
  7.  say "Usage: recopy <from> <to> [<block size>]"
  8.  say "   <from> <to>  : source and destination file names"
  9.  say "   <block size> : Size of block for copying. Default value is 2048 bytes."
  10.  say "                  Use larger value for faster hosts"
  11.  return
  12. end
  13. if bl<>'' then blocksize=bl
  14. say "Copying "||fr||" -> "||t
  15. if stream(t,'c','OPEN WRITE')<>"READY:" then
  16. do
  17.  say "Can't open destination"
  18.  exit
  19. end
  20. a=stream(t,"c","QUERY SIZE")
  21. if (a='') then a=0
  22. if stream(fr,'c','OPEN READ')<>"READY:" then
  23. do
  24.  say "Can't open source"
  25.  exit
  26. end
  27. sz=stream(fr,"c","QUERY SIZE")-(a+1)
  28. call time 'r'
  29. call stream fr,'c','seek ='||(a+1)
  30. do while stream(fr,'s')='READY'
  31.  s=charin(fr,,blocksize)
  32.  call charout t,s
  33.  p=(stream(fr,'c','seek')-(a+1))
  34.  eta=(sz-p)/(p/time(e))
  35.  etah=eta%3600
  36.  etas=''
  37.  if etah<>0 then etas=etah||':'
  38.  etam=trunc((eta%60)//60)
  39.  etas=etas||etam||':'
  40.  etas=etas||trunc(eta//60)
  41.  call charout, d2c(13)||p||' bytes copied ('||trunc((p/sz)*100,1)||'%) cps='trunc(p/time('e'))||' ETA='||etas||'     '
  42. end
  43. call lineout ,'a'x'd'x'Done in '||trunc(time('e'))||' seconds'
  44. call stream fr,'c','close'
  45. call stream t,'c','close'
  46.  
  47.