home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxapfd.zip / rc3.cmd < prev    next >
OS/2 REXX Batch file  |  1993-10-16  |  2KB  |  99 lines

  1. /* Rexx */
  2.  
  3. sigstr = 'Signal On Syntax;Signal Off Error;Signal Off Failure;'
  4. logfile = 'c:\rc3.log'
  5.  
  6. Signal On Syntax
  7.  
  8. /* This exec executes any valid Rexx instruction group sent from a */
  9. /* partner LU */
  10.  
  11. Address "CMD" "@Echo Off"
  12.  
  13. If RxFuncQuery('rxAPPC') Then
  14.   Call RxFuncAdd 'rxAPPC','rxappcfd','rxappcfd'
  15. If rxfuncquery('syssleep') Then
  16.   Do
  17.   Call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  18.   Call SysLoadFuncs
  19.   End
  20. If RxFuncQuery('RXRSOE2F') Then
  21.   Do
  22.   Call RxFuncAdd 'RxYdbaUtilInit','YDBAUTIL','RxYdbaUtilInit'
  23.   Call RxYdbaUtilInit
  24.   End
  25.  
  26. call rxseterror 'he'
  27.  
  28. convtype = 'mfn'       /* mapped, full-duplex, non-blocking */
  29. rswd = 'y'
  30.  
  31. appcrc = rxAppc('Receive_Allocate','RC3','Inf.')
  32. If appcrc = 0 Then
  33.   Do
  34.   tpid =   inf.1
  35.   convid = inf.2
  36.   incoming_user = inf.5
  37.   partlu = inf.7
  38.   partmode = inf.8
  39.   End
  40. Else
  41.   Do
  42.   call lineout logfile,'Receive_Allocate failed with rc =' appcrc
  43.   Exit
  44.   End
  45.  
  46. appcrc = rxappc('Receive_and_Wait',convtype,tpid,convid,rswd,10000,'inf.')
  47. If appcrc <> 0 Then
  48.   Do
  49.   call lineout logfile,'Receive_and_Wait failed with rc =' appcrc
  50.   Call rxAppc 'Tp_Ended', tpid,'s'
  51.   Exit
  52.   End
  53. inf.5 = cryption(inf.5)
  54. Parse Var inf.5 upmid upmpw .
  55. rxupmrcu = RxUpm('Logon',upmid,upmpw,'Local',,'User')
  56. rxupmrca = RxUpm('Logon',upmid,upmpw,'Local',,'Admin')
  57. If rxupmrcu <> 0 | rxupmrca <> 0 Then
  58.   Do
  59.   Call rxAppc 'Send_Error',convtype,tpid,convid,'p','s','inf.'
  60.   Call rxAppc 'Tp_Ended', tpid,'s'
  61.   Exit
  62.   End
  63.  
  64. /* Create an un-named pipe and get its read & write handles */
  65. rxrc = rxcreatepipe('h.',32765)
  66. hread  = h.1
  67. hwrite = h.2
  68.  
  69. /* Re-direct standard out & error to pipe's write handle */
  70. call rxsose2h hwrite
  71.  
  72. tid = rxcreaterexxthread('rc4', partlu, partmode, hread, hwrite, tpid, convid)
  73.  
  74. Restart_From_Here:
  75.  
  76. appcrc = rxappc('Receive_and_Wait',convtype,tpid,convid,rswd,10000,'inf.')
  77. Do While Appcrc = 0
  78.   cmdstr = cryption(inf.5)
  79.   say 'Command String:';say '  'cmdstr;say 'Command Result:';Say
  80.   Interpret sigstr||cmdstr
  81.   Say ' '
  82.   appcrc = rxappc('Receive_and_Wait',convtype,tpid,convid,rswd,10000,'inf.')
  83. End
  84.  
  85. Call rxAppc 'Tp_Ended', tpid,'s'
  86. call rxkillthread tid
  87.  
  88. Exit
  89.  
  90. Syntax:
  91. msg = 'Command "'cmdstr'"'
  92. call lineout logfile,msg;say msg
  93. msg = 'Failed with syntax error ('rc')' ErrorText(rc)
  94. call lineout logfile,msg;say msg
  95. Signal Restart_From_Here
  96.  
  97. Cryption:
  98. Return BitXor(Arg(1),Copies('ff'x,Length(Arg(1))))
  99.