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

  1. /* Rexx */
  2.  
  3. /* This
  4.  
  5. /* Register Rexx external functions */
  6. If RxFuncQuery('RXACSMGT') Then
  7.   Call RxFuncAdd 'RXACSMGT','YDBAACSM','YDBAACSM'
  8. If RxFuncQuery('rxappc') Then
  9.   Call RxFuncAdd 'rxappc','rxappcfd','rxappcfd'
  10. If RxFuncQuery('SYSSLEEP') Then
  11.   Do
  12.   Call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  13.   Call SysLoadFuncs
  14.   End
  15. If RxFuncQuery('RxCreateRexxThread') Then
  16.   Do
  17.   Call RxFuncAdd 'RxYdbaUtilInit','YDBAUTIL','RxYdbaUtilInit'
  18.   Call RxYdbaUtilInit
  19.   End
  20.  
  21. Call RxAcsMgt 'display_sna_global_info','sg.'
  22. loclu=sg.4;Drop sg.
  23.  
  24. /* Prompt user */
  25. Say;Say 'Enter LU-Alias of remote workstation:'
  26. Say '(Type * to end)'
  27. Parse Upper LineIn partlu
  28. If partlu = '*' Then
  29.   Exit
  30. pq = partlu
  31. If Pos('.',pq) > 0 Then
  32.   Parse Var pq . '.' pq
  33.  
  34. /* Set security info */
  35. Say;Say 'Enter userid, followed by password:'
  36. Parse Upper LineIn uidpw
  37. uidpw = Space(Translate(uidpw,' ',','))
  38.  
  39. If uidpw = '*' Then
  40.   si = 'None'
  41. Else
  42.   Do
  43.   If Words(uidpw) <> 2 Then
  44.     Do
  45.     Say 'You must supply both a userid and a password.'
  46.     Exit
  47.     End
  48.   Parse Var uidpw uid pw .
  49.   si = 'Pgm' uid pw
  50.   End
  51.  
  52. call syscls
  53.  
  54. appcrc = rxappc('Tp_Started', loclu, 'RC1', 'tpid')
  55. If appcrc <> 0 Then
  56.   Do;Say;Say 'Tp_Started failed with rc =' appcrc
  57.   Exit
  58.   End
  59. Signal On Syntax Name Trap_Allocate_Syntax
  60. convtype = 'mfn'       /* mapped, full-duplex, non-blocking */
  61. synclvl = 'n'
  62. retctl = 'a'
  63. convstyle = 's'
  64. mode = '#INTER'
  65. ptp = 'RC3'
  66. appcrc = rxAppc('Allocate',convtype,tpid,synclvl,retctl,convstyle,
  67.                ,partlu,mode,ptp,si,'inf.')
  68. Signal Off Syntax
  69. If appcrc <> 0 Then
  70.   Do;Say;Say 'Mc_Allocate failed with rc =' appcrc
  71.   Call rxAppc 'Tp_Ended', tpid, 's'
  72.   Exit
  73.   End
  74. convid = inf.1
  75. appcrc = rxappc('Send_Data',convtype,tpid,convid,'n',Cryption(uid pw),'inf.')
  76. If appcrc <> 0 Then
  77.   Do;Say;Say 'Send_Data (uid/pw) failed with rc =' appcrc
  78.   Call rxAppc 'Tp_Ended', tpid,'s'
  79.   Exit
  80.   End
  81.  
  82. appcrc = rxappc('Flush',convtype,tpid,convid,)
  83. If appcrc <> 0 Then
  84.   Do;Say;Say 'Flush (uid/pw) failed with rc =' appcrc
  85.   Call rxappc 'Tp_Ended', tpid,'s'
  86.   Exit
  87.   End
  88.  
  89. If rxpmprintf(pq,' ') = 0 Then
  90.   Do
  91.   Call rxstartsession 'pmprintf.exe','queue' pq,'Child'
  92.   call syssleep 3
  93.   End
  94.  
  95. call rxcreaterexxthread 'rc2', pq, tpid, convid
  96.  
  97. Do Forever
  98.   call syscls
  99.   Say Center('Issuing Commands at Remote Workstation "'partlu'"',50)
  100.   Say;Say 'Enter string to be interpreted by Rexx on remote workstation:'
  101.   Say '(Type * to terminate)'
  102.   Parse LineIn cmdstr
  103.   If cmdstr = '*' Then
  104.     Leave
  105.   If cmdstr = '' Then
  106.     cmdstr = ' '
  107.   Call Process_CmdStr
  108. End
  109.  
  110. Call rxappc 'Deallocate', convtype, tpid, convid, 's','inf.'
  111. Call rxappc 'Tp_Ended', tpid,'s'
  112.  
  113. Exit
  114.  
  115. /* ======================================================================= */
  116. /* Process Command String                                                  */
  117. /* ======================================================================= */
  118. Process_CmdStr:
  119.  
  120. appcrc = rxappc('Send_Data',convtype,tpid,convid,'n',Cryption(cmdstr),'inf.')
  121. If appcrc <> 0 Then
  122.   Do;Say;Say 'Send_Data failed with appcrc =' appcrc
  123.   Call rxappc 'Tp_Ended', tpid,'s'
  124.   Exit
  125.   End
  126.  
  127. appcrc = rxappc('Flush',convtype,tpid,convid,)
  128. If appcrc <> 0 Then
  129.   Do;Say;Say 'Flush failed with appcrc =' appcrc
  130.   Call rxappc 'Tp_Ended', tpid,'s'
  131.   Exit
  132.   End
  133.  
  134. Return
  135.  
  136. Trap_Allocate_Syntax:
  137. Say 'Partner LU name' partlu 'is invalid.'
  138. Say 'It must be either an lu-alias (1-8 chars), or a fully qualified name'
  139. Say '(1-8 char network name, a period, and a 1-8 char lu-name).'
  140. Address 'CMD' '@PAUSE'
  141. Exit
  142.  
  143. Cryption:
  144. Return BitXor(Arg(1),Copies('ff'x,Length(Arg(1))))
  145.