home *** CD-ROM | disk | FTP | other *** search
/ Merciful 3 / Merciful_Release_3.bin / software / c / crashmailv1.22reg.lha / CrashMail / rexx / James.rexx < prev    next >
OS/2 REXX Batch file  |  1995-02-17  |  2KB  |  105 lines

  1. /*
  2.  
  3.    Butler James -- A sample ARexx mail robot
  4.  
  5.    James understands the following two commands:
  6.  
  7.    Info
  8.    Avail
  9.  
  10.    Both execute the command with the same name in C: and send the output
  11.    back in a mail to the sender. James can handle normal FidoNet netmails
  12.    as well as gated e-mails from Usenet as long as they have the REPLYNAME
  13.    and REPLYADDR kludges as specified in FSC-0035.
  14.  
  15. */
  16.  
  17. IF ~SHOW(Libraries,'rexxsupport.library') THEN
  18.     IF ~ADDLIB("rexxsupport.library",0,-30,0) THEN EXIT
  19.  
  20. parse arg file
  21.  
  22. kg=TRUE
  23.  
  24. to=""
  25. toaddr=""
  26. from=""
  27. fromname=""
  28. replyaddr=""
  29. replytoaddr="2:200/427.3"
  30. replytoname="uucp"
  31.  
  32. call open('file',file,'R')
  33.  
  34. do while kg=TRUE
  35.  str = readln('file')
  36.  
  37.  if eof('file') then do
  38.    kg=FALSE
  39.  end
  40.  else if length(str)=0 then do
  41.    kg=FALSE
  42.  end
  43.  else do
  44.    if left(str,5)="From:" then parse var str 'From: 'fromaddr'@'dummy' ('fromname')'
  45.    if left(str,3)="To:" then parse var str 'To: 'toaddr'@'dummy' ('toname')'
  46.    if left(str,14)="X-Fido-REPLYTO" then parse var str 'X-Fido-REPLYTO 'replytoaddr' 'replytoname
  47.    if left(str,16)="X-Fido-REPLYADDR" then parse var str 'X-Fido-REPLYADDR 'replyaddr
  48.  end
  49. end
  50.  
  51. call open('out','T:James.tmp','W')
  52. call close('out')
  53.  
  54. if replyaddr~="" then do
  55.    fromaddr=replytoaddr
  56.    fromname=replytoname
  57.  
  58.    call open('out','T:James.tmp','A')
  59.    call writeln('out',"To: " || replyaddr)
  60.    call writeln('out',"")
  61.    call close('out')
  62. end
  63.  
  64. kg=TRUE
  65.  
  66. do while kg=TRUE
  67.     str = readln('file')
  68.  
  69.     if left(str,3)="---" then do
  70.       kg=FALSE
  71.     end
  72.     else if length(str)>0 then do
  73.        call open('out','T:James.tmp','A')
  74.        call writeln('out'," > " || str);
  75.        call writeln('out',"");
  76.        call close('out')
  77.  
  78.        if str="avail" then address command "avail >>T:James.tmp"
  79.        else if str="info" then address command "info >>T:James.tmp"
  80.        else do
  81.           call open('out','T:James.tmp','A')
  82.           call writeln('out',"Unknown command");
  83.           call close('out')
  84.        end
  85.  
  86.        call open('out','T:James.tmp','A')
  87.        call writeln('out',"");
  88.        call close('out')
  89.    end
  90.  
  91.    if eof('file') then do
  92.       kg=FALSE
  93.    end
  94. end
  95.  
  96. call close('file')
  97.  
  98. /* Send the mail using CrashWrite */
  99.  
  100. address command 'Work:UMS/CrashMail/CrashWrite FN "Butler James" FA 'toaddr' TN "'fromname'" TA 'fromaddr' SUBJ "Butler James at your service, sir!" t:James.tmp'
  101. call delete("T:James.tmp")
  102. address command 'Run >NIL: <NIL: rx "address 'CRASHMAIL' toss"'
  103.  
  104. exit 10
  105.