Stat Custom Object Type That Creates Symbolic Link To fndcpesr

Many of our developers create UNIX shell script current programs that require a symbolic link to $FND_TOP/bin/fndcpesr.  Stat can easily handle the shell script but not the symbolic link.  Growing tired of having to manually create these symbolic links, I decided to create a Stat custom object type that will copy the UNIX shell script and execute a custom shell script to handle creating the symbolic link.

Stat’s object class “Oracle Apps File Objects” will by default copy the file during migration, so that takes care of copying the shell script.  Now to handle the symbolic link, I created a shell script that will take care of creating the symbolic link to fndcpesr.  Stat will need to pass the object name to the shell script.  Until Stat 5.6.4 comes out, Stat can only pass the predefined parameter: TARGET_OBJECT_NAME.  That parameter is just the file name without the directory. I was able to get around that because we have only one Custom shell script directory that houses our shell script concurrent programs.  So the shell script assumes the directory name. The script will create the symbolic link only when a file or link does not already exist.  For example:  if the target_object_name is: CustomShell.prog, a symbolic link: CustomShell to $FND_TOP/bin/fndcpesr is created when a link or file with that name does not exist. So the script will not overwrite a file or link if it already exists.

Make sure to modify your PATH environment variable in your script that starts your Stat EBS agent to include the directory location of this symbolic link script.  You will also need to place this script on each of your “For Concurrent Mgr” hosts.  

See the screen shots below showing the Custom Object, the migration output and the shell script.

Screen below shows the definition of Custom object “All prog Files in ADP_TOP/bin”.  File extension is “.prog”   The script will strip out the .prog before creating the symbolic link.

Screen below shows the Stat File Location for the prog object.

Below is the migration output generated by Stat.  The script produces the Event log output

Script will not overwrite a file or link if it already exists.

# ----------------------------------------------------------------------------
# Script:  /home/stat/scripts/
# Purpose: Script to handle Creating a Softlink file from $FND_TOP/bin/fndcpesr in ADP_TOP/bin
#          for the value passed in with the -f argrument
#          only when it does not exist
# Args:   1): Name of Softlink to create
# Example: /home/stat/scripts/ -f MyScript.prog
# ----------------------------------------------------------------------------
# Written: Thomas Shaw  14-Jan-2013
# ----------------------------------------------------------------------------
# Modifications:
# ----------------------------------------------------------------------------
PROGRAM=`basename $0`
USAGE="\nUsage:\n$PROGRAM -f SoftLinkName\n"

while getopts "f:" opt
  case $opt in
    f) SoftLink=$OPTARG;;
    ?) print $USAGE
       exit 1;;

if [[ "`whoami`" != "$RunUser" ]]
   echo "\n`date` : Must be run by UNIX user: $RunUser\n"
   exit 1

# Make sure file exists and is a regular file
if [ -f "$SoftLink" ] ; then
   echo "\n Error:  File does not exits with -f switch\n"
   exit 1

### Strip out the file extension
x=`echo $SoftLink | grep -i .prog | wc -l`
if [ x -gt 0 ] ; then
   SL="`echo $SoftLink | sed 's/.prog//' | sed 's[./[['`"

   # Only create a link when either nothing already exists
   if [[ -a "${ADP_TOP}/bin/${SL}" ]] ; then
      echo "\nFile or Softlink already exists with the same name: `ls -l ${ADP_TOP}/bin/${SL}`\n"
      ln -s ${FND_TOP}/bin/fndcpesr ${ADP_TOP}/bin/${SL}

      if [[ $ErrCode -eq 0 ]] ; then
         ### ls -l ${ADP_TOP}/bin/${SL}
         echo "Softlink created: `ls -l  ${ADP_TOP}/bin/${SL}`\n"
         echo "\nSoftlink creation failed with Code: $ErrCode\n"
         exit $ErrCode

   echo "\nFile Name does not end in .prog SoftLink Not Created\n"