This script will help you to unlock the all jobs, if you are a DS admin, or your datastage jobs , if a DS developer, without doing human error while executing command on Datastage server UV shell or Datastage Administrator Client.
Script is quite simple, Execute it , it will ask for Project Name and Job Name and Done if you have appropriate access on Datastage server.
May be need a modification as per your Datastage platform or if you need some fancy stuff to add on. Happy Scripting !!
==========================================================================================================
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/ksh | |
#====================================================================# | |
#FILENAME:DS_JOB_Lock_REALESE.sh # | |
#USAGE:DS_JOB_Lock_REALESE.sh # | |
#VERSION:V0.1 # | |
#--------------------------------------------------------------------# | |
#AUTOR: Atul Singh # | |
#DATE:15/02/2014 # | |
#====================================================================# | |
#====================================================================# | |
# Initialization Section # | |
#====================================================================# | |
echo "This job releases the lock held on the logfile of a job" | |
echo "=======================================================" | |
printf "Accept the DS Project Name : " | |
read PROJNAME | |
printf "Accept the DS Job Name : " | |
read JOBNAME | |
JOBNO="" | |
# source the dsenv file | |
. dsenv | |
# Locating the DSEngine folder of Datastage | |
if [ -f /.dshome ]; then | |
cd `cat /.dshome` | |
cd bin | |
else | |
cd ../bin | |
fi | |
# Adding UNLOCK command to the VOC | |
(echo "LOGTO $PROJNAME"; echo "SET.FILE UV VOC UV.VOC"; echo "COPY FROM UV.VOC TO VOC UNLOCK") | ./uvsh > /dev/null 2>&1 | |
#====================================================================# | |
# Function_Name: get_job_no # | |
# Description : get_job_no # | |
# Parameters : None # | |
#====================================================================# | |
get_job_no( ) | |
{ | |
JOBNO=`(echo "LOGTO $PROJNAME"; echo "select * from DS_JOBS where @ID='$JOBNAME'"; echo; echo "Q") | ./uvsh | grep "No\.\.\.\.\." | tr -s " " " " | cut -d" " -f2` | |
if [[ $JOBNO == "" ]]; then | |
echo "Either the jobname or the project name is not set correctly... Please check the cases (upper/lower) as well... " | |
exit 1 | |
else | |
echo "Job number for $JOBNAME = $JOBNO" | |
fi | |
} | |
# Fetching the job number for the given job from the Metadata repository | |
#====================================================================# | |
# Function_Name: release_joblock_by_rtconfig # | |
# Description : release_joblock_by_rtconfig # | |
# Parameters : None # | |
#====================================================================# | |
# Fetching the user number by RT_CONFIG | |
release_joblock_by_rtconfig () | |
{ | |
echo "Fetching the user number by RT_CONFIG$JOBNO now......." | |
USERNO=`(echo "LOGTO $PROJNAME"; echo "LIST.READU"; echo; echo "Q") | ./uvsh | grep "RT_CONFIG$JOBNO" | tr -s " " " " | cut -d" " -f5` | |
if [[ $USERNO == "" ]]; then | |
echo "No locks held on the logfile of the job $JOBNAME by RT_CONFIG$JOBNO " | |
else | |
for user in $USERNO | |
do | |
echo "User number for the logfile = $user" | |
# Releasing all the locks held by the user number retreived | |
(echo "LOGTO $PROJNAME"; echo "UNLOCK USER $user ALL"; echo; echo "Q") | ./uvsh > /dev/null 2>&1 | |
done | |
echo "The lock of job $JOBNAME is released by RT_CONFIG$JOBNO....." | |
fi | |
} | |
#====================================================================# | |
# Function_Name: release_joblock_by_rtlog # | |
# Description : release_joblock_by_rtlog # | |
# Parameters : None # | |
#====================================================================# | |
# Fetching the user number holding the lock on RT_LOGn where n is the job number retreived | |
release_joblock_by_rtlog () | |
{ | |
echo "Fetching the user number by by RT_LOG$JOBNO now......." | |
USERNO=`(echo "LOGTO $PROJNAME"; echo "LIST.READU"; echo; echo "Q") | ./uvsh | grep "RT_LOG$JOBNO" | tr -s " " " " | cut -d" " -f5` | |
if [[ $USERNO == "" ]]; then | |
echo "No locks held on the logfile of the job $JOBNAME by RT_LOG$JOBNO" | |
else | |
for user in $USERNO | |
do | |
echo "User number for the logfile = $user" | |
# Releasing all the locks held by the user number retreived | |
(echo "LOGTO $PROJNAME"; echo "UNLOCK USER $user ALL"; echo; echo "Q") | ./uvsh > /dev/null 2>&1 | |
done | |
echo "The lock on log of job $JOBNAME is released by RT_LOG$JOBNO....." | |
fi | |
} | |
#====================================================================# | |
# Function_Name: release_joblock_by_jobname # | |
# Description : release_joblock_by_jobname # | |
# Parameters : None # | |
#====================================================================# | |
# Fetching the user number by JOBNAME | |
release_joblock_by_jobname () | |
{ | |
echo "Fetching the user number by $JOBNAME now......." | |
USERNO=`(echo "LOGTO $PROJNAME"; echo "LIST.READU"; echo; echo "Q") | ./uvsh | grep "$JOBNAME" | tr -s " " " " | cut -d" " -f5` | |
if [[ $USERNO == "" ]]; then | |
echo "No locks held on the logfile of the job $JOBNAME by $JOBNAME" | |
else | |
for user in $USERNO | |
do | |
echo "User number for the logfile = $user" | |
# Releasing all the locks held by the user number retreived | |
(echo "LOGTO $PROJNAME"; echo "UNLOCK USER $user ALL"; echo; echo "Q") | ./uvsh > /dev/null 2>&1 | |
done | |
echo "The lock on log of job $JOBNAME is released by $JOBNAME....." | |
fi | |
} | |
#====================================================================# | |
# Main Section # | |
#====================================================================# | |
# | |
get_job_no | |
release_joblock_by_rtconfig | |
release_joblock_by_rtlog | |
release_joblock_by_jobname | |
exit 0 | |
# End of script |
==========================================================================================================
Like the Facebook Page & join Group
https://www.facebook.com/DataStage4you
https://www.facebook.com/groups/DataStage4you
https://twitter.com/datastage4you
https://groups.google.com/d/forum/datastage4you
For WHATSAPP group , drop a msg to 91-88-00-906098
No comments :
Post a Comment