home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / cpymsg.zip / cpymsg.cmd next >
OS/2 REXX Batch file  |  1997-07-07  |  2KB  |  52 lines

  1. /* CPYMSG.cmd - Julian Thomas 1997: rexx script to append msg to file */
  2. /* Version 0.01 */
  3. /* based on code from William H. Geiger III */
  4. /* whgiii@amaranth.com */
  5.  
  6. parse arg outfilename msg_filename .
  7. if msg_filename = '' then do
  8.    say 'usage is cpymsg outfile infile'
  9.    say 'can be called from msgutil or used standalone; purpose'
  10.    say 'is to append a message (omitting some junk from the header)'
  11.    say 'to a file to build a digest or whatever.'
  12.    exit
  13.    end
  14. '@echo off'
  15. blank=''
  16. fence='=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+'
  17. m.=''
  18. m.1="From:"
  19. m.2="To:"
  20. m.3="Date:"
  21. m.4="Subject:"
  22. m.5="Message-ID:"
  23. m.6="Reply-To:"
  24. m.7="Sender"
  25. m.0=7
  26.  
  27. nxy=1
  28. nxz=stream(outfilename,'c','open write')
  29. nxz=stream(outfilename,'c','seek <0')
  30. nzz=stream(msg_filename,'c','open read')
  31. do forever while (length(linein(msg_filename))>0) /* pull file header */
  32. nxx=stream(msg_filename,'c','seek +0')            /* get read pointer */
  33. nxx_rs=stream(msg_filename,'c','seek =' nxy)      /* reset read pointer */
  34. lin=linein(msg_filename)
  35.    /* test to see if we put it out */
  36.    headout=0
  37.    do i=1 to m.0 by 1
  38.    if pos(m.i,lin)=1 then headout=1 
  39.    end /* loop */
  40. if headout=1 then lo=lineout(outfilename,lin)
  41. nxy=stream(msg_filename,'c','seek +0')
  42. end
  43. lo=lineout(outfilename,blank)
  44. do forever while lines(msg_filename)
  45.    lin=linein(msg_filename)
  46.    lo=lineout(outfilename,lin)
  47.    end
  48. st1=stream(msg_filename,'c','close')
  49. lo=lineout(ouffilename,fence)
  50. st3=stream(outfilename,'c','close')
  51. exit
  52.