Sure, no problem, here goes the script I'm using:
#!/usr/bin/ksh
# ovw_map_copy script
# Purpose: Automatically copy the default NNM map to all ITO users
# Argument: None
# Dependency: None
# Output: File $UNCOPIED_LIST contains a list of maps that couldn't
# be copied because user was logged on at the time the script
# was last executed
# Return value: 0 -> Success
# 1 -> Error
#
# Creation date: 01/31/2001
# Created by: Carlos Garcia -vlan52- cgarcia@optiglobe.com.ar
# Last modified on: 03/09/2001
# ChangeLog: 20010309: included (ovwchown operator $MAP_NAME;ovwchgrp opcgrp $MAP_NAME); included opc_adm map copy.
#
#
# Load environment variables
. /opt/OV/bin/ov.envvars.sh
# Define some environment variables
# File where list of current out-of-date maps is stored
UNCOPIED_LIST=$OV_CONF/ovw_uncopied_maps
# Temporary file to store the new list of out-of-date maps
TMP_LIST=/tmp/tmp_ovw_uncopied_maps
# Name of file where copy operation output will be logged
LOG_NAME=$OV_LOG/ovw_mapcopy.log
# Name of map to be copied to all the users. Typically 'default'
DEFAULT_MAP_NAME=default
# Maximum number of lines in logfile
NUM_LINES=200
# Erase temporary list of uncopied maps
if [ -f $TMP_LIST ]
then
rm $TMP_LIST
fi
# If list of uncopied maps doesn't exist, create an empty one
if [ ! -f $UNCOPIED_LIST ]
then
touch $UNCOPIED_LIST
fi
# Initialize logfile
>> $LOG_NAME
date >> $LOG_NAME
echo "---- Starting copy of $DEFAULT_MAP_NAME map..." >> $LOG_NAME
# Test if the default map exists
if [ ! -d $OV_DB/openview/mapdb/$DEFAULT_MAP_NAME ]
then
# Default map doesn't exist, abort
echo "$DEFAULT_MAP_NAME map not found. Aborting."
echo "ERROR: Default map '$DEFAULT_MAP_NAME' not found. Aborting" >> $LOG_NAME
echo "---- End of map copy" >> $LOG_NAME
exit 1
fi
# Begin to loop through map names
ls -l $OV_DB/openview/mapdb/ | grep "^d" | grep -v $DEFAULT_MAP_NAME | awk '{ print $9}' | while read MAP_NAME
do
$OV_BIN/ovw -deleteMap $MAP_NAME
if [ $? = 1 ]
then
# Couldn't delete map, user is probably logged in
if [ `grep -c $MAP_NAME $UNCOPIED_LIST` != 0 ]
then
# Couldn't copy map for the second time. Generate an error
echo "ERROR: Couldn't copy $DEFAULT_MAP_NAME map to map
$MAP_NAME for the second time."
echo "ERROR: Couldn't copy $DEFAULT_MAP_NAME map to map $MAP_NAME for the second time. Run script again when user $MAP_NAME is disconnected." >> $LOG_NAME
# Uncomment the following line if you want to inform ITO about the problem.
# Make sure appropriate template will match the message text
# $OV_BIN/OpC/opcmsg severity=minor application=OpC object="NNM map $MAP_NAME" msg_text='Unable to copy $DEFAULT_MAP_NAME map to user $MAP_NAME during the last two shifts. Run the script again when user $MAP_NAME is logged of IT/O" msg_grp=Job
fi
# Keep a log of uncopied map name
echo $MAP_NAME >> $TMP_LIST
else
# Could delete map. Try to copy the default map
$OV_BIN/ovw -copyMap $DEFAULT_MAP_NAME $MAP_NAME
if [ $? = 1 ]
then
# Default map exists, destination map has been erased
# but copy failed. Abort script, there could be a problem
# with the default map
echo "Couldn't copy map $DEFAULT_MAP_NAME to map named $MAP_NAME\nPlease try the command mannually and restore map $MAP_NAME"
echo "Scipt aborted during copy of map $MAPNAME. Copy the default map ($DEFAULT_MAP) manually, and check error messages" >> $LOG_NAME
exit 1
else
#change map owner/group:
$OV_BIN/ovwchown operator $MAP_NAME
$OV_BIN/ovwchgrp opcgrp $MAP_NAME
echo "Successfully copied default map to map $MAP_NAME" >> $LOG_NAME
fi
fi
done
#change opc_adm owner/group back to root/sys:
$OV_BIN/ovwchown root opc_adm
$OV_BIN/ovwchgrp sys opc_adm
# Close logfile entry
echo "--- Finished map copy" >> $LOG_NAME
# Update the list of uncopied maps:
mv $TMP_LIST $UNCOPIED_LIST
# Trim logfile to desired size
tail -n $NUM_LINES >> $TMP_LIST
mv $TM_LIST $LOG_NAME
# Exit properly
exit 0
Hope this helps Vickdu, regards,
vlan52
![[sunshine] [sunshine] [sunshine]](/data/assets/smilies/sunshine.gif)
vlan52
The end of wisdom is freedom. The end of culture is perfection. The end of
education is character. The end of knowledge is love.