home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / rxsnd111.zip / rexxsend.cmd
OS/2 REXX Batch file  |  1994-02-11  |  7KB  |  273 lines

  1. /***********************************************************************/
  2. /*                                                                     */
  3. /* Rexxsend.Cmd v1.11 - John Cuccia   02/06/94                         */
  4. /*                                                                     */
  5. /*  Usage:                                                             */
  6. /*                                                                     */
  7. /*    RexxSend /ftextfile /lsendlist /amsgarea /bbasetype /tmailtype   */
  8. /*             /ssendfile                                              */
  9. /*                                                                     */
  10. /*  TEXTFILE is a file containing the text of the message to be sent.  */
  11. /*                                                                     */
  12. /*  SENDLIST is the list of nodes to which the message will be sent.   */
  13. /*                                                                     */
  14. /*  MSGAREA is the area in which the message(s) will be posted.  Use   */
  15. /*    the root filename (omit the .SQD extension) for squish areas or  */
  16. /*    the directory name for *.MSG areas.                              */
  17. /*                                                                     */
  18. /*  BASETYPE is either "S" for Squish-style areas or "F" for           */
  19. /*    Fido-style *.MSG areas.                                          */
  20. /*                                                                     */
  21. /*  MAILTYPE is either "N" for Netmail or "E" for Echomail.            */
  22. /*                                                                     */
  23. /*  SENDFILE is the fully qualified filename of a file to be attached  */
  24. /*                                                                     */
  25. /*  SENDFILE is optional, all other arguments are required             */
  26. /*                                                                     */
  27. /*  You must precede all command line options with either a forward    */
  28. /*  slash (/) or a dash (-).                                           */
  29. /*                                                                     */
  30. /***********************************************************************/
  31.  
  32. '@echo off'
  33.  
  34. ver='1.1'
  35.  
  36. i=1
  37. parse upper arg arg.i rest
  38.  
  39. do while rest <> ''
  40.   i=i+1
  41.   parse upper var rest arg.i rest
  42. end
  43.  
  44. argcount=i
  45. sendflag=0
  46.  
  47. if argcount < 5 then
  48.   do
  49.     error=1
  50.     signal parmerror
  51.   end
  52.  
  53. do i=1 to argcount
  54.   if left(arg.i,1)<>'/' & left(arg.i,1)<>'-' then
  55.     do
  56.       error=3
  57.       signal parmerror
  58.     end
  59. end
  60.  
  61. do i=1 to argcount
  62.   if substr(arg.i,2,1) ='F' then
  63.     textfile=substr(arg.i,3)
  64.   if substr(arg.i,2,1)= 'L' then
  65.     sendlist=substr(arg.i,3)
  66.   if substr(arg.i,2,1)= 'A' then
  67.     msgarea=substr(arg.i,3)
  68.   if substr(arg.i,2,1)= 'B' then
  69.     basetype=substr(arg.i,3)
  70.   if substr(arg.i,2,1)= 'T' then
  71.     mailtype=substr(arg.i,3)
  72.   if substr(arg.i,2,1)= 'S' then
  73.     do
  74.       sendfile=substr(arg.i,3)
  75.       sendflag=1
  76.     end
  77. end
  78.  
  79. if basetype <> 'F' & basetype <> 'S' then
  80.   do
  81.     error=4
  82.     signal parmerror
  83.   end
  84.  
  85. if mailtype <> 'N' & mailtype <> 'E' then
  86.   do
  87.     error=5
  88.     signal parmerror
  89.   end
  90.  
  91. if stream(textfile,'c','query exists') = '' then
  92.   call nofile(textfile)
  93.  
  94. if stream(sendlist,'c','query exists') = '' then
  95.   call nofile(sendlist)
  96.  
  97. if sendflag = 1 then
  98.   do
  99.     if stream(sendfile,'c','query exists') = '' then
  100.       call nofile(sendfile)
  101.   end
  102.  
  103. if rxfuncquery(sysfiletree) <> 0 then
  104.   call rxfuncadd 'sysfiletree','rexxutil','sysfiletree'
  105.  
  106.  
  107. if basetype=='S' then
  108.   msgtype='SQUISH'
  109. else
  110.   msgtype='SDM'
  111.  
  112. if mailtype=='N' then
  113.   areatype='NET'
  114. else
  115.   areatype='ECHO'
  116.  
  117. if msgtype == 'SDM' then
  118.   do
  119.     rc=sysfiletree(msgarea,stemres,'D',,)
  120.     if stemres.0 \= 1 then
  121.       signal noareafound
  122.     else
  123.       nop
  124.   end
  125. else
  126.   do
  127.     if stream(msgarea'.SQD','c','query exists') = '' then
  128.      call nofile(msgarea'.SQD')
  129.     else
  130.       nop
  131.   end
  132.  
  133.  
  134. cr = '0d'x
  135. tagtext = cr'--- RexxSend v'ver||cr
  136. origin = ' * Origin: Cajunet (1:3803/1)'cr
  137.  
  138. filesize=stream(textfile,'c','query size')
  139. msgtext=charin(textfile,1,filesize)
  140. text=msgtext||tagtext
  141.  
  142. if areatype == 'ECHO' then
  143.   text=text||origin
  144.  
  145. parse value date(S) with today
  146. yyyy=left(today,4)
  147. mo=substr(today,5,2)
  148. dd=right(today,2)
  149. yy=right(yyyy,2)
  150.  
  151. parse value time() with hh':'mm':'ss
  152.  
  153. call rxfuncadd 'rxydbautilinit','ydbautil','rxydbautilinit'
  154. call rxydbautilinit
  155.  
  156. address CMD 'rxsubcom register MSGAPI rxmsgapi RXMSGAPI'
  157. address CMD 'rxsubcom load MSGAPI RXMSGAPI'
  158.  
  159. send1= rxexeci(sendlist,,payors.,'s')
  160. parse var send1 paylread paybread
  161.  
  162. controla = '01'x
  163. /*control = controla || 'PID RXMSGAPI'*/
  164. control = ''
  165. if areatype == 'NET' then
  166.   xmsg.attr = 385
  167. else
  168.   xmsg.attr = 256
  169. xmsg.from = 'John Cuccia'
  170. if sendflag = 1 then
  171.   do
  172.     if areatype == 'NET' then
  173.       do
  174.         xmsg.subj = sendfile
  175.         xmsg.attr=xmsg.attr+16
  176.       end
  177.     else
  178.       xmsg.subj = '.....'
  179.   end
  180. else
  181.   xmsg.subj = '.....'
  182. xmsg.orig = '1:3803/1.0'
  183. xmsg.utc_ofs = 360
  184. xmsg.replyto = 0
  185. xmsg.replies.1 = 0
  186. xmsg.replies.2 = 0
  187. xmsg.replies.3 = 0
  188. xmsg.replies.4 = 0
  189. xmsg.replies.5 = 0
  190. xmsg.replies.6 = 0
  191. xmsg.replies.7 = 0
  192. xmsg.replies.8 = 0
  193. xmsg.replies.9 = 0
  194. xmsg.replies.10 = 0
  195. xmsg.ftsc_date = dd||' '||left(date('M'),3)||' '||yy||'  'hh':'mm':'ss
  196.  
  197. address MSGAPI
  198. 'OPEN_API 1 0'
  199. 'OPEN_AREA MSG' msgarea 'MSGAREA_NORMAL' msgtype
  200. 'LOCK MSG'
  201.  
  202. say ''
  203.  
  204. do count=1 to paylread
  205.  
  206.   parse var payors.count addr name
  207.  
  208.   if payors.count == '' then leave
  209.  
  210.   XMSG.to=name
  211.  
  212.   if substr(right(addr,2),1,1) <>'.' then
  213.     XMSG.dest=addr||'.0'
  214.   else
  215.     XMSG.dest=addr
  216.  
  217.   'OPEN_MSG MSGH MSG MOPEN_CREATE 0'
  218.  
  219.   XMSG.date_written=yyyy'/'mo'/'dd||':'||time('N')
  220.   XMSG.date_arrived=XMSG.date_written
  221.  
  222.   'WRITE_MSG MSGH 0 XMSG. TEXT' length(text) length(text) length(control) 'CONTROL'
  223.   'CLOSE_MSG MSGH'
  224.   say '       Creating message for' XMSG.to
  225.  
  226. end
  227.  
  228. 'UNLOCK MSG'
  229. 'CLOSE_AREA MSG'
  230. 'CLOSE_API'
  231.  
  232. signal cleanup
  233.  
  234. nofile:
  235.   parse arg filename
  236.   say 'File 'filename' not found'
  237.   signal cleanup
  238.  
  239. noareafound:
  240.   say 'directory 'msgarea' not found'
  241.   signal cleanup
  242.  
  243. parmerror:
  244.   say 'RexxSend v'ver 'usage:'
  245.   say ''
  246.   say '   RexxSend /ftextfile /lsendlist /amsgarea /bbasetype /tmailtype /ssendfile'
  247.   say ''
  248.   say 'TEXTFILE is a file containing the text of the message to be sent.'
  249.   say ''
  250.   say 'SENDLIST is the list of nodes to which the message will be sent.'
  251.   say ''
  252.   say 'MSGAREA is the area in which the message(s) will be posted.  Use'
  253.   say '  the root filename (omit the .SQD extension) for squish areas or'
  254.   say '  the directory name for *.MSG areas.'
  255.   say ''
  256.   say 'BASETYPE is either "S" for Squish-style areas or "F" for *.MSG areas.'
  257.   say ''
  258.   say 'MAILTYPE is either "N" for Netmail or "E" for Echomail.'
  259.   say ''
  260.   say 'SENDFILE is the fully qualified name of a file to be attached.'
  261.   say ''
  262.   say '    SENDFILE is optional, all other arguments are required'
  263.   say ''
  264.   say '    You must precede all command line options with either a forward'
  265.   say '    slash (/) or a dash (-).'
  266.  
  267. cleanup:
  268.   if rxfuncquery(rxexeci) = 0 then
  269.     call rxydbautilterm
  270.   address CMD 'rxsubcom drop MSGAPI'
  271.   exit
  272.  
  273.