home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
netdor3.zip
/
DISK_12
/
IMAGE11.ZIP
/
ADMTOOLS
/
MULTCMD.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-08-20
|
6KB
|
144 lines
/*****************************************************************************
* MULTCMD - Execute a Command on Multiple Servers *
* T. Bridgman (CORE at WATSON) *
*****************************************************************************
* Licensed Materials-Property of IBM *
* 5604-472 (c) Copyright IBM Corporation, 1993 *
* All rights reserved. *
* US Government Users Restricted Rights - *
* Use, duplication or disclosure restricted *
* by GSA ADP Schedule Contract with IBM Corp. *
*****************************************************************************
* Change History *
* version 1.0 - 10 Oct 90 *
* version 1.1 - 8 Sep 91 *
* - Support command line or function call *
* - Support any server, not just domain controllers *
* - Allow server names to optionally be preceeded by '\\' *
* - Add /S option to silence the commentary. *
* 30 Oct 91 - teb *
* - Add support to pass strings of multiple commands to servers. *
*****************************************************************************/
trace 'O'
'@ECHO OFF'
parse source . How .
CmdMode = (How = 'COMMAND')
if CmdMode
then parse arg Command ',' MachList
else parse arg Command, MachList
parse upper var MachList MachList '/' SlashParms
/**** PTR 93 start ****/
if SlashParms <> ''
then SlashParms = translate('/'SlashParms)
/**** PTR 93 end ****/
if abbrev(Command, '?') | Command = '' | MachList = ''
then signal Tell
call LoadRxUtils
if rxos2ver() < 1.2
then call Error 'MULTCMD requires OS/2 1.2 or later.'
Command = ProcessCmd(Command)
/**** PTR 93 start ****/
Quiet = wordpos('/S', SlashParms)
if Quiet > 0
then SlashParms = strip(space(delword(SlashParms, Quiet, 1)))
Quiet = (Quiet > 0)
if SlashParms <> ''
then do
say 'Error: Invalid parameters specified:' SlashParms
exit 2
end
/**** PTR 93 end ****/
call Msg
call Msg 'Performing "'Command'"...'
do until MachList = ''
parse var MachList Machine MachList
if left(Machine, 2) <> '\\'
then Machine = '\\'Machine
call Msg '...on' Machine':'
'NET.EXE ADMIN' Machine' /C' Command
if rc <> 0
then call Msg 'rc('rc')'
call Msg
end
if CmdMode
then exit 0
else return 0
Msg:
if \Quiet
then say arg(1)
return
/*****************************************************************************
* PROCESSCMD *
*****************************************************************************/
ProcessCmd: procedure
parse arg Cmd
P0 = pos('&', Cmd)
do while P0 <> 0
if substr(Cmd, P0-1, 1) <> '^'
then do
Cmd = left(Cmd, P0-1)'^'substr(Cmd, P0)
P0 = P0+1
end
P0 = pos('&', Cmd, P0+1)
end
if left(Cmd, 1) <> '(' then Cmd = '('Cmd
if right(Cmd, 1) <> ')' then Cmd = Cmd')'
return Cmd
/*****************************************************************************
* ERROR *
*****************************************************************************/
Error:
parse arg EMsg
say d2c(7)EMsg
if CmdMode
then exit 2
else return 2
LoadRxUtils: procedure
if \rxfuncadd('RXLOADFUNCS', 'RXUTILS', 'RXLOADFUNCS')
then do
signal on syntax name LoadRxUtils2
call rxLoadFuncs 'QUIET'
end
return 0
LoadRxUtils2:
signal off syntax /* Turn off temp error trap */
/* If you have an error trap in the program, use the following line inste
signal on syntax name syntax
*/
select
when rc = 40
then call rxLoadFuncs
when rc = 43
then do
say 'Error: RXUTILS.DLL not found.'
exit 2
end
otherwise do
say 'Error: Error' rc 'registering RXUTILS functions.'
exit 2
end
end
return 0
Tell:
say
say 'MULTCMD command, server [...] [/S]'
say
say 'Execute the specified command on multiple servers.'
say 'MULTCMD can be called as a function or from the command line.'
say
say ' /S - don''t provide any commentary.'
say
say 'To pass strings of commands joined by the & or && operators,'
say 'remember to insert a caret (^) before each & symbol: ^& or ^&^&'
exit 0