home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
remcmd.zip
/
REMCMDC1.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-05-10
|
4KB
|
168 lines
/* Rexx */
pq = 'REMCMD'
/* Register Rexx external functions */
If RxFuncQuery('RXACSMGT') Then
Call RxFuncAdd 'RXACSMGT','YDBAACSM','YDBAACSM'
If RxFuncQuery('APPC') Then
Call RxFuncAdd 'APPC','SAAAPPC','APPCSRV'
If RxFuncQuery('SYSSLEEP') Then
Do
Call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
Call SysLoadFuncs
End
If RxFuncQuery('RxCreateRexxThread') Then
Do
Call RxFuncAdd 'RxYdbaUtilInit','YDBAUTIL','RxYdbaUtilInit'
Call RxYdbaUtilInit
End
Call Define_Callback_Tp
Call RxAcsMgt 'display_sna_global_info','sg.'
loclu=sg.4;Drop sg.
/* Prompt user */
Say;Say 'Enter LU-Alias of remote workstation:'
Say '(Type * to end)'
Parse Upper LineIn partlu
If partlu = '*' Then
Exit
/* Set security info */
Say;Say 'Enter userid, followed by password:'
Parse Upper LineIn uidpw
uidpw = Space(Translate(uidpw,' ',','))
If uidpw = '*' Then
si = 'None'
Else
Do
If Words(uidpw) <> 2 Then
Do
Say 'You must supply both a userid and a password.'
Exit
End
Parse Var uidpw uid pw .
si = 'Pgm' uid pw
End
call syscls
appcrc = Appc('Tp_Started', loclu, 'REMCMDC1', 'inf.')
If appcrc <> 0 Then
Do;Say;Say 'Tp_Started failed with rc='xlatrxap(appcrc)
Exit
End
tpid = inf.0
Signal On Syntax Name Trap_Allocate_Syntax
appcrc = Appc('Allocate',tpid,partlu,'#INTER','REMCMDC3','Mapped',
, 'A','N',si,'Inf.')
Signal Off Syntax
If appcrc <> 0 Then
Do;Say;Say 'Mc_Allocate failed with rc='xlatrxap(appcrc)'.'
Say 'Primary Rc ='c2x(inf.2);
Say 'Secondary Rc='c2x(inf.3)
Say 'Sense Code ='c2x(inf.4)
Call Appc 'Tp_Ended', tpid
Exit
End
convid = inf.1
appcrc = Appc('Send_Data', tpid, convid, 'Mapped', Cryption(uid pw))
If appcrc <> 0 Then
Do;Say;Say 'Send_Data (uid/pw) failed with rc='xlatrxap(appcrc)'.'
Call Appc 'Tp_Ended', tpid
Exit
End
appcrc = Appc('Flush', tpid,convid, 'Mapped')
If appcrc <> 0 Then
Do;Say;Say 'Flush (uid/pw) failed with rc='xlatrxap(appcrc)'.'
Call Appc 'Tp_Ended', tpid
Exit
End
If rxpmprintf(pq,' ') = 0 Then
Do
Call rxstartsession 'pmprintf.exe','queue' pq,'Child'
call syssleep 3
End
call rxcreaterexxthread 'remcmdc2', pq
Do Forever
call syscls
Say Center('Issuing Commands at Remote Workstation "'partlu'"',50)
Say;Say 'Enter string to be interpreted by Rexx on remote workstation:'
Say '(Type * to terminate)'
Parse LineIn cmdstr
If cmdstr = '*' Then
Leave
If cmdstr = '' Then
cmdstr = ' '
Call Process_CmdStr
End
Call Appc 'Deallocate', tpid, convid, 'Mapped', 'Sync_Level'
Call Appc 'Tp_Ended', tpid
Exit
/* ======================================================================= */
/* Process Command String */
/* ======================================================================= */
Process_CmdStr:
appcrc = Appc('Send_Data', tpid, convid, 'Mapped', Cryption(cmdstr))
If appcrc <> 0 Then
Do;Say;Say 'Send_Data failed with rc='xlatrxap(appcrc)'.'
Call Appc 'Tp_Ended', tpid
Exit
End
appcrc = Appc('Flush', tpid, convid, 'Mapped')
If appcrc <> 0 Then
Do;Say;Say 'Flush failed with rc='xlatrxap(appcrc)'.'
Call Appc 'Tp_Ended', tpid
Exit
End
Return
Trap_Allocate_Syntax:
Say 'Partner LU name' partlu 'is invalid.'
Say 'It must be either an lu-alias (1-8 chars), or a fully qualified name'
Say '(1-8 char network name, a period, and a 1-8 char lu-name).'
Address 'CMD' '@PAUSE'
Exit
Cryption:
Return BitXor(Arg(1),Copies('ff'x,Length(Arg(1))))
/* Define call-back TP */
Define_Callback_Tp:
progfile = ''
Drop tp.
tp.2 = 'REMCMDC2' /* tp name */
tp.3 = progfile /* tp filespec */
tp.4 = '' /* argument */
tp.5 = '' /* icon filespec */
tp.6 = 'mapped' /* conv type */
tp.7 = 'no' /* conv security */
tp.8 = 'none' /* sync level */
tp.9 = 'Operator_Started' /* how to run program */
tp.10 = 'Vio_windowable' /* program type */
tp.11 = 1 /* queue_depth_limit */
tp.12 = 'infinite' /* incoming_alloc_timeout */
tp.13 = 'infinite' /* receive_alloc_timeout */
acsrc = rxacsmgt('define_tp','tp.')
If acsrc <> 0 Then
Do
Call rxpmprintf pq,'Define_Tp for REMCMDC2 failed with acsrc =' acsrc
Exit
End
Return