home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / remcmd.zip / REMCMDC3.CMD < prev    next >
OS/2 REXX Batch file  |  1993-05-10  |  3KB  |  99 lines

  1. /* Rexx */
  2.  
  3. Parse Source . . WhoAmI
  4. sigstr = 'Signal On Syntax;Signal Off Error;Signal Off Failure;'
  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('APPC') Then
  14.   Call RxFuncAdd 'APPC','SAAAPPC','APPCSRV'
  15. If RxFuncQuery('RXRSOE2F') Then
  16.   Do
  17.   Call RxFuncAdd 'rxydbautilinit','ydbautil','rxydbautilinit'
  18.   call rxydbautilinit
  19.   End
  20. If RxFuncQuery('SQLDBS') Then
  21.   Call RxFuncAdd 'SQLDBS', 'SQLAR', 'SQLDBS'
  22. If RxFuncQuery('SQLEXEC') Then
  23.   Call RxFuncAdd 'SQLEXEC', 'SQLAR', 'SQLEXEC'
  24.  
  25. appcrc=Appc('Receive_Allocate','REMCMDC3','Inf.')
  26. If appcrc = 0 Then
  27.   Do
  28.   tpid =   inf.0
  29.   convid = inf.1
  30.   incoming_user = inf.4
  31.   partlu = inf.6
  32.   partmode = inf.7
  33.   End
  34. Else
  35.   Do
  36.   Say 'Receive_Allocate failed with rc =' xlatrxap(appcrc)
  37.   Exit
  38.   End
  39.  
  40. appcrc = Appc('Receive_Wait',tpid, Convid, 'Mapped', 'CmdStr.',10000)
  41. If appcrc <> 0 Then
  42.   Do
  43.   Say 'Receive_Wait failed with rc =' xlatrxap(appcrc)
  44.   Call Appc 'Tp_Ended', tpid
  45.   Exit
  46.   End
  47. cmdstr.2 = Cryption(cmdstr.2)
  48. Parse Var cmdstr.2 upmid upmpw .
  49. rxupmrcu = RxUpm('Logon',upmid,upmpw,'Local',,'User')
  50. rxupmrca = RxUpm('Logon',upmid,upmpw,'Local',,'Admin')
  51. If rxupmrcu <> 0 | rxupmrca <> 0 Then
  52.   Do
  53.   Call Appc 'Send_Error', tpid, convid, 'Mapped', 'Program'
  54.   Call Appc 'Tp_Ended', tpid
  55.   Exit
  56.   End
  57.  
  58. /* Create an un-named pipe and get its read & write handles */
  59. rxrc = rxcreatepipe('h.',32765)
  60. hread  = h.1
  61. hwrite = h.2
  62.  
  63. /* Re-direct standard out & error to pipe's write handle */
  64. call rxsose2h hwrite
  65.  
  66. tid = rxcreaterexxthread('remcmdc4', partlu, partmode, hread, hwrite)
  67.  
  68. Restart_From_Here:
  69.  
  70. appcrc = Appc('Receive_Wait',tpid, Convid, 'Mapped', 'CmdStr.',10000)
  71. Do While Appcrc = 0
  72.   cmdstr = ''
  73.   /*****************************
  74.   Do While Appcrc = 0 & cmdstr.0 <> 1     /* Accumulate the pieces */
  75.     cmdstr.2 = Cryption(cmdstr.2)
  76.     cmdstr = cmdstr||cmdstr.2
  77.     appcrc = Appc('Receive_Wait',tpid, Convid, 'Mapped', 'CmdStr.',10000)
  78.   End
  79.   *****************************/
  80.   cmdstr = cryption(cmdstr.2)
  81.   Say 'Command String:';Say '  'cmdstr;Say 'Command Result:';Say
  82.   Interpret sigstr||cmdstr
  83.   Say ' '
  84.   appcrc = Appc('Receive_Wait',tpid, Convid, 'Mapped', 'CmdStr.',10000)
  85. End
  86.  
  87. Call Appc 'Tp_Ended', tpid
  88. call rxkillthread tid
  89.  
  90. Exit
  91.  
  92. Syntax:
  93. Say 'Command "'cmdstr'"'
  94. Say 'Failed with syntax error ('rc')' ErrorText(rc)
  95. Signal Restart_From_Here
  96.  
  97. Cryption:
  98. Return BitXor(Arg(1),Copies('ff'x,Length(Arg(1))))
  99.