home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR21
/
ALIASMOV.ZIP
/
ALIASMOV.CMD
next >
Wrap
OS/2 REXX Batch file
|
1992-05-11
|
9KB
|
267 lines
/**************** REXX *************************************************/
/* Moves an alias between servers or between paths on a server or both */
/***********************************************************************/
parse upper arg AliasName DestUNC
if DestUNC = '' then
do
say ' '
say 'Usage is: aliasmov <Alias Name> <Dest UNC name>'
say 'Function: To move an alias between paths and preserve the access '
say ' control profile for all subdirectories'
exit
end
call ParseDestUNC
call GetAliasInfo
call StopShare
call CreateNewAlias
call SetAccess
call CopyData
exit
/***********************************************************************/
/* ParseDestUNC: Parse dest UNC name and break into server and */
/* path parts */
/* Replace the $ in the path with a : */
/***********************************************************************/
ParseDestUNC:
/* Get server name */
DestServer = left(DestUNC, pos('\', DestUNC, 3) - 1)
/* Get path and translate $ to : */
DestPath = right(DestUNC, length(DestUNC) - pos('\', DestUNC, 3))
DestPath = translate(DestPath, ':', '$')
return
/***********************************************************************/
/* GetAliasInfo: Get information on the source alias */
/***********************************************************************/
GetAliasInfo:
'rxqueue /clear'
/* Get Alias info */
'net alias 'AliasName' | rxqueue /FIFO'
if queued() = 0 then
/* Alias doesn't exist */
do
say 'Alias 'AliasName' does not exist in this domain'
exit 2
end
parse pull junk /* Alias name line */
parse pull junk':' AliasDesc /* Alias description line */
AliasDesc = strip(AliasDesc)
/* Translate " to ' in the description */
AliasDesc = translate(AliasDesc, '''', '"') ;
parse pull junk':' SourceServer /* Alias Server line */
SourceServer = strip(SourceServer)
parse pull junk':' SourcePath /* Alias path line */
SourcePath = strip(SourcePath)
parse upper pull junk':' AliasWhenShare /* When shared line */
AliasWhenShare = strip(AliasWhenShare)
parse upper pull junk':' AliasUserLimit /* Max users line */
AliasUserLimit = strip(AliasUserLimit)
parse pull junk
SourceUNC = SourceServer||'\'||SourcePath
SourceUNC = translate(SourceUNC, '$', ':')
return
/***********************************************************************/
/* StopShare: Turn off the share on the Source Server */
/***********************************************************************/
StopShare:
'net admin 'SourceServer' /c net share 'AliasName' /d'
return
/***********************************************************************/
/* CreateNewAlias: Creates the new alias and sets initial access */
/***********************************************************************/
CreateNewAlias:
/* Delete old alias */
'net alias 'AliasName' /d'
/* Create new alias */
Command = 'net alias 'AliasName DestServer DestPath
/* Set "remark" parameter */
if AliasDesc \= '' then
Command = Command '/REMARK:"'AliasDesc'"'
/* Set "when shared" parameter */
select
when AliasWhenShare = 'AS REQUIRED BY USER' then
Command = Command '/WHEN:REQUESTED'
when AliasWhenShare = 'AT SERVER STARTUP' then
Command = Command '/WHEN:STARTUP'
when AliasWhenShare = 'BY ADMINISTRATOR' then
Command = Command '/WHEN:ADMIN'
otherwise
end
/* Set "number of users" parameter */
if AliasUserLimit = 'NO LIMIT' then
Command = Command '/UNLIMITED'
else
Command = Command '/USERS:'AliasUserLimit
Command
return
/***********************************************************************/
/* CopyData: Copy the data between paths */
/* This does not use NET COPY because NET COPY will not copy */
/* subdirectories */
/***********************************************************************/
CopyData:
SourceDrive = left(SourceUNC, pos('$', SourceUNC))
DestDrive = left(DestUNC, pos('$', DestUNC))
SourceSubPath = right(SourceUNC, length(SourceUNC) - pos('$', SourceUNC))
DestSubPath = right(DestUNC, length(DestUNC) - pos('$', DestUNC))
'net use s: /d'
'net use t: /d'
'net use s: 'SourceDrive
'net use t: 'DestDrive
'echo y | xcopy s:'SourceSubPath' t:'DestSubPath' /s /e'
'net use s: /d'
'net use t: /d'
return
/***********************************************************************/
/* SetAccess: Get access permissions from source and set them for the */
/* destination */
/***********************************************************************/
SetAccess:
'rxqueue /clear'
/* Get Access Control Profile info */
'net admin 'SourceServer' /c net access 'SourcePath' | rxqueue /FIFO'
/* Get first line */
parse upper pull junk
/* Error handling */
if junk = 'NO ENTRIES IN LIST.' then
do
say 'Could not find access control profile info for Alias 'AliasName
say 'Aborting...'
exit
end
if word(junk,1) = 'NET2222:' then
do
say 'Could not find the alias when trying to get access control info for'
say ' alias 'AliasName
say 'Aborting...'
exit
end
/* Get dashed line */
parse pull junk
/* Get resources and access info until done. Blank line delimits resources */
linecount = queued()
i = 0
/* Get info on resource */
parse upper pull Resource Auditing
i = i + 1
/* Get access control info until end of input */
parse pull line
i = i + 1
AccCnt = 0
do while line \= '' & i < linecount
temp = word(line, 1)
temp = strip(temp)
if temp \= '' then
do
AccCnt = AccCnt + 1
Access.AccCnt = AccessCleanup(temp)
end
temp = word(line,2)
if temp \= '' then
do
AccCnt = AccCnt + 1
Access.AccCnt = AccessCleanup(temp)
end
parse pull line
i = i + 1
end
Access.0 = AccCnt
/* Create Access Control profile in new position */
do j = 1 to Access.0
if AccessGrant(DestServer, DestPath, Access.j) = 'Not OK' then
if AccessAdd(DestServer, DestPath, Access.j) = 'Not OK' then
say 'Could not set access permissions of 'Access.j' for 'DestPath
end
/* Set auditing setting */
if Auditing \= '' then
do
select
when Auditing = '( AUDITED )' then
'net admin 'DestServer' /c net access 'DestPath' /trail:yes'
when Auditing = '( AUDITED - FAILURE:ALL )' then
'net admin 'DestServer' /c net access 'DestPath' /failure:all'
when Auditing = '( AUDITED - SUCCESS:ALL )' then
'net admin 'DestServer' /c net access 'DestPath' /success:all'
otherwise
end
end
return
/***********************************************************************/
/* Access Cleanup: Remove the * and cleanup the access information */
/***********************************************************************/
AccessCleanup: procedure
Access = arg(1)
Access = translate(Access, '', '*')
/* Convert the word (none) to access rights of N */
if right(Access, length(Access) - pos(':', Access)) = '(none)' then
Access = left(Access, pos(':', Access)) || 'N'
return Access
/***********************************************************************/
/* AccessAdd: Do net access with Add parameter */
/***********************************************************************/
AccessAdd: procedure
Server = arg(1)
Path = arg(2)
Access = arg(3)
NewQ = rxqueue('Create')
OldQ = rxqueue('Set', NewQ)
'net admin 'Server' /c net access 'Path' /add 'Access' | rxqueue 'NewQ' /FIFO'
parse pull line
say line
call rxqueue 'Delete', NewQ
call rxqueue 'Set', OldQ
if word(line, 1) = 'The' then
return 'OK'
else
return 'Not OK'
/***********************************************************************/
/* AccessGrant: Do net access with Grant parameter */
/***********************************************************************/
AccessGrant: procedure
Server = arg(1)
Path = arg(2)
Access = arg(3)
NewQ = rxqueue('Create')
OldQ = rxqueue('Set', NewQ)
'net admin 'Server' /c net access 'Path' /grant 'Access' | rxqueue 'NewQ' /FIFO'
parse pull line
say line
call rxqueue 'Delete', NewQ
call rxqueue 'Set', OldQ
/* Check to see if the */
if word(line,1) = 'The' then
return 'OK'
else
return 'Not OK'