home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ibm370 / ikcaux.cmd < prev    next >
OS/2 REXX Batch file  |  2020-01-01  |  6KB  |  215 lines

  1. :READ KERMAIL EXEC A
  2. /*
  3. Date: Wed, 26 Jun 91 08:20:26 MEZ
  4. From: Erwin Halpern <Z00EHR01@AWIUNI11.BITNET>
  5.  
  6.   KERMAIL EXEC T
  7.  
  8.   Purpose:
  9.      Route MAIL received from MS-KERMIT via CMS-KERMIT
  10.      to MAILER for distribution.
  11.  
  12.   Requirements:
  13.      At least one Read/Write-disk accessed
  14.  
  15.   Call:
  16.      Is done internally by CMS-KERMIT
  17.  
  18.   Function:
  19.      CMS-KERMIT calls KERMAIL once with the argument "." to assure
  20.      that KERMAIL is available. In this case KERMAIL returns with RC=0.
  21.      Then when CMS-KERMIT has received the mail-file from the PC, it
  22.      calls KERMAIL with the (Arg) format shown below.  KERMAIL now looks
  23.      if FN FT FM really exists and sends it to MAILER via MAIL.
  24. */
  25.  
  26. Arg fn ft fm '(' mailids '(' mailopts
  27. if fn = '' | fn = "." then return 0
  28. 'SET CMSTYPE HT'
  29. 'STATE' fn ft fm
  30. rrc=-rc
  31. if rrc ^= 0 then do
  32.    'SET CMSTYPE RT'
  33.     return rrc
  34. end
  35. 'MAIL' mailids '( NOE NOL NOPR F' fn ft fm mailopts
  36. rrc=rc
  37. if rrc > 0 then rrc=-rrc
  38. 'SET CMSTYPE RT'
  39. 'ERASE' fn ft fm
  40. return rrc
  41. :READ KERMPRT EXEC A
  42. &TRACE *
  43. *-------------------------------------------------------------
  44. * KERMPRT EXEC - Sample command for driving PRINT distribution
  45. *         jfc   90/06/25
  46. *------------------------------------------------------------
  47. &IF &N LT 2 &EXIT 0
  48. &X = -1 + &LOCATION OF ( &ARGSTRING
  49. &IF &X LT 3 &EXIT -20
  50. &FILEID = &LEFT OF &ARGSTRING &X
  51. &X = 2 + &X
  52. &OPTIONS = &PIECE OF &ARGSTRING &X
  53. &UPPER VARS &OPTIONS
  54. * -- COULD CHECK SYNTAX HERE ...
  55. SENTRIES
  56. &STACKSIZE = &RC
  57. EXECIO * CP (LIFO ST QUERY VIRTUAL 009
  58. SENTRIES
  59. &STACKSIZE = &RC - &STACKSIZE
  60. &LOOP 1 &STACKSIZE
  61.   &READ STRING &X
  62. &CHR = &PIECE OF &X 9 1
  63. &TERM = 23
  64. &IF .&CHR NE . &TERM = &TERM + 2
  65. &START = &TERM + 7
  66. &TERM = &PIECE OF &X &TERM 6
  67. &START = &PIECE OF &X &START 5
  68. CP SPOOL 9 NOTERM START
  69. &PRINT -- KERMPRT SENDING &FILEID TO PRINTER
  70. PRINT &FILEID (&OPTIONS
  71. &R = &RC
  72. &IF .&START NE .START CP SPOOL 9 PURGE
  73. EXECIO 0 CP (SKIP ST SPOOL 9 &TERM &START
  74. &IF &R NE 0 &EXIT -20
  75. ERASE &FILEID
  76. &EXIT 0
  77. :READ PC EXEC A
  78. /*   PC Exec - J.F. Chandler - 1992 April
  79.    (modified 1995 to use APC instead of obsolete TERMINALS)
  80.  
  81.    Intended to be executed either from inside Kermit or out.
  82.    If used within Kermit, remember to SET SYSCMD ON.
  83.  
  84.    Syntax:  PC cmd
  85.    The PC Kermit is placed in server mode via APC, then the "cmd"
  86.    is executed, and then a FINISH is executed.
  87.  
  88.    Typical examples: PC SEND fn ft
  89.                      PC GET file.ext
  90.  
  91.    Special case:  PC PRINT file
  92.    The printer is enabled via ANSI escape sequence, the file is then
  93.    displayed, and the printer is disabled.
  94. */
  95. Parse Arg cmd
  96. If Words(cmd) <= 1 Then Do
  97.   Say 'Missing parameter(s)'
  98.   Exit 99
  99.   End
  100. Trace OFF
  101. print = Abbrev('PRINT',Word(cmd,1),2)
  102. If Right(Strip(cmd),1) = ',' Then Do
  103.   Say 'Syntax error'
  104.   Exit 99
  105.   End
  106. If print Then Do
  107.   open_cmd = 'XECHO ^[[5i'      /* Enable printer */
  108.   cmd = 'XTYPE' Subword(cmd,2)
  109.   close_cmd = 'XECHO ^[[4i'     /* Disable printer */
  110.   End
  111. Else Do
  112.   open_cmd = 'APC SERVER'       /* start server */
  113.   close_cmd = 'FINISH'
  114.   End
  115. Address KERMIT open_cmd
  116. If rc<>0 Then Signal INVOKE     /* Kermit not started yet */
  117. Address KERMIT cmd
  118. r = rc
  119. Address KERMIT close_cmd
  120. Select
  121.   When r=2  Then Say 'Transfer cancelled'
  122.   When r=5  Then Say 'Bad packet count or chksum'
  123.   When r=6  Then Say 'Invalid packet syntax'
  124.   When r=7  Then Say 'Invalid packet type'
  125.   When r=8  Then Say 'Lost a packet'
  126.   When r=9  Then Say 'Micro sent a NAK'
  127.   When r=10 Then Say 'Micro aborted'
  128.   When r=12 Then Say 'File not found'
  129.   When r=13 Then Say 'Disk or file is full'
  130.   When r=14 Then Say 'Disk I/O error'
  131.   When r=15 Then Say 'Missing operand'
  132.   When r=17 Then Say 'Syntax error'
  133.   When r=19 Then Say 'Records truncated'
  134.   When r=20 Then Say 'Bad communication line'
  135.   When r=21 Then Say '8th-bit quote not set'
  136.   When r=22 Then Say 'File too short'
  137.   When r=23 Then Say 'Missing start-of-packet'
  138.   When r=24 Then Say 'Option error on filespec'
  139.   When r=25 Then Say 'Unable to dispose of file'
  140.   Otherwise Nop
  141.   End
  142. Exit r
  143. *
  144. INVOKE:
  145. Push 'QUIT'
  146. Push close_cmd
  147. Push cmd
  148. Push open_cmd
  149. Address CMS 'KERMIT'
  150. :READ PC OLD A
  151. /*   PC Exec - J.F. Chandler - 1992 April
  152.    (modified December to use TERMINALS instead of TERMINLR)
  153.  
  154.    Intended to be executed either from inside Kermit or out.
  155.    Syntax:  PC cmd
  156.    The PC Kermit is placed in server mode via TERMINALS, then the "cmd"
  157.    is executed, and then a FINISH is executed.
  158.  
  159.    Special case:  PC PRINT file
  160.    The printer is enabled via ANSI escape sequence, the file is then
  161.    displayed, and the printer is disabled.
  162. */
  163. Parse Arg cmd
  164. If Words(cmd) <= 1 Then Do
  165.   Say 'Missing parameter(s)'
  166.   Exit 99
  167.   End
  168. Trace OFF
  169. print = Abbrev('PRINT',Word(cmd,1),2)
  170. If Right(Strip(cmd),1) = ',' Then Do
  171.   Say 'Syntax error'
  172.   Exit 99
  173.   End
  174. If print Then Do
  175.   open_cmd = 'XECHO ^[[5i'      /* Enable printer */
  176.   cmd = 'XTYPE' Subword(cmd,2)
  177.   close_cmd = 'XECHO ^[[4i'     /* Disable printer */
  178.   End
  179. Else Do
  180.   open_cmd = 'XECHO ^[[?34h    ^[[?34h'    /* start server (extra) */
  181.   close_cmd = 'FINISH'
  182.   End
  183. Address KERMIT open_cmd
  184. If rc<>0 Then Signal INVOKE     /* Kermit not started yet */
  185. Address KERMIT cmd
  186. r = rc
  187. Address KERMIT close_cmd
  188. Select
  189.   When r=2  Then Say 'Transfer cancelled'
  190.   When r=5  Then Say 'Bad packet count or chksum'
  191.   When r=6  Then Say 'Invalid packet syntax'
  192.   When r=7  Then Say 'Invalid packet type'
  193.   When r=8  Then Say 'Lost a packet'
  194.   When r=9  Then Say 'Micro sent a NAK'
  195.   When r=10 Then Say 'Micro aborted'
  196.   When r=12 Then Say 'File not found'
  197.   When r=13 Then Say 'Disk or file is full'
  198.   When r=14 Then Say 'Disk I/O error'
  199.   When r=15 Then Say 'Missing operand'
  200.   When r=17 Then Say 'Syntax error'
  201.   When r=19 Then Say 'Records truncated'
  202.   When r=20 Then Say 'Bad communication line'
  203.   When r=22 Then Say 'File too short'
  204.   When r=23 Then Say 'Missing start-of-packet'
  205.   Otherwise Nop
  206.   End
  207. Exit r
  208. *
  209. INVOKE:
  210. Push 'QUIT'
  211. Push close_cmd
  212. Push cmd
  213. Push open_cmd
  214. Address CMS 'KERMIT'
  215.