Showing posts with label Shell Script. Show all posts
Showing posts with label Shell Script. Show all posts

Thursday, 22 May 2014

Converting Special Character in Unix Shell Script

#!/bin/ksh
##########################################################################
#
# Parameters
# 1 = Batch file name
##########################################################################
PROGRAM_NAME=`basename $0`
echo $PROGRAM_NAME "has started"
echo " "
########################################
# Concurrent Program parameters #
########################################
#total_args=`echo $*|awk '{print NF}'`
##############
# File Name #
##############
BATCH_FILE=`echo $*|awk '{print $9}' | sed 's/"//g'`
BATCH_FILE=`eval "echo $BATCH_FILE"`
echo "Batch file = " ${BATCH_FILE}
###################
# Data Directory #
###################
DATA_DIR=`echo $*|awk '{print $10}' | sed 's/"//g'`
DATA_DIR=`eval "echo $DATA_DIR"`
echo "Data Dir = " ${DATA_DIR}
############################
# Environmental variables. #
############################
START_TIME=`date +%d-%b-%Y" "%H:%M`
HOST_NAME=`uname -n`
TSTAMP=`date '+%Y%m%d%H%M%S'`
EXIT_STATUS='SUCCESS'
BATCH_SOURCE=`echo ${DATA_DIR}/${BATCH_FILE}`
#################################################
# Converting the file #
#################################################
cat ${BATCH_SOURCE}|sed "s/$(printf "\243")//g">${BATCH_SOURCE}.new
mv ${BATCH_SOURCE}.new ${BATCH_SOURCE}
cat ${BATCH_SOURCE}|sed '/^\:61\:/s/ *//'>${BATCH_SOURCE}.new
mv ${BATCH_SOURCE}.new ${BATCH_SOURCE}
###############
## Final exit #
###############
 EXIT_STATUS='SUCCESS'
 echo "SEAS_CE_sh Status :" $EXIT_STATUS
 END_TIME=`date +%d-%b-%Y" "%H:%M`
 echo "Program Completed .... " $END_TIME
 echo "Moved ${BATCH_SOURCE}.new to ${BATCH_SOURCE}"
 exit 0
fi

#

Unix Shell Script to Copy Files from One Directory to Another Directory

---------------------------------------------------------------------------
Unix Shell Script to Copy Files from One Directory to Another Directory
---------------------------------------------------------------------------
#!/bin/ksh
################################################################
# Display
the banner to announce that the program has started.
#################################################################
PROGRAM_NAME
=`basename $0`echo $PROGRAM_NAME "has started"
echo " "
########################################
# Oracle Concurrent
Program parameters #########################################
#total_args
=`echo $*|awk '{print NF}'`##############
#
Source File###############
SOURCE_FILE
=`echo $*|awk '{print $9}' | sed 's/"//g'`SOURCE_FILE
=`eval "echo $SOURCE_FILE"`echo "
Source file = " ${SOURCE_FILE}###################
#
Data Directory ####################
DATA_DIR
=`echo $*|awk '{print $10}' | sed 's/"//g'`DATA_DIR
=`eval "echo $DATA_DIR"`echo "
Data Dir = " ${DATA_DIR}###################
# Arch
Directory ####################
ARCH_DIR
=`echo $*|awk '{print $11}' | sed 's/"//g'`ARCH_DIR
=`eval "echo $ARCH_DIR"`echo "
Archive Dir = " ${ARCH_DIR}############################
# Environmental variables
. #############################
START_TIME
=`date +%d-%b-%Y" "%H:%M`HOST_NAME
=`uname -n`TSTAMP
=`date '+%Y%m%d%H%M%S'`EXIT_STATUS
='SUCCESS'
BATCH_SOURCE=`echo ${DATA_DIR}/${SOURCE_FILE}`BATCH_TARGET
=`echo ${ARCH_DIR}/${SOURCE_FILE}`
#################################################
#
Move the file ##################################################
mv ${BATCH_SOURCE} ${BATCH_TARGET}
###############
##
Final exit ################
EXIT_STATUS
='SUCCESS'echo "SEASAPAR Status :" $EXIT_STATUSEND_TIME
=`date +%d-%b-%Y" "%H:%M`echo "
Program Completed .... " $END_TIMEecho "Moved ${BATCH_SOURCE}
to ${BATCH_TARGET}"
exit 0 fi

#

Oracle Apps Concurrent program Output as Email

Using the below Unix SH file we can send the Concurrent program Output as Email.Please

pass the request id of the Concurrent program and email address.

#!/bin/ksh
#################################
# Parameters
# 1 = echo "Start of the Program"
#################################
# File Name #
##############
REQUEST_ID=`echo $*awk '{print $9}' sed 's/"//g'`
REQUEST_ID=`eval "echo $REQUEST_ID"`
echo "Request Id= " ${REQUEST_ID}
###################
# Enail #
###################
mail_add=`echo $* awk '{print $10}' tr -d "`
echo "mail id : ${mail_add}"
req_file='${req_id}.out'
###################
# Data Directory #
###################
cd $APPLCSF/$APPLOUT
uuencode ${REQUEST_ID} ${REQUEST_ID} mailx -v -s"XXX Banks Accounts&PO expense
Creation Out File" "$mail_add"

Sunday, 18 May 2014

How to submit the concurrent request from shell scripts

CONCSUB utility used for submit the concurrent request from shell scripts. CONCSUB are described in the "System Administration User Guide" as follow:

$ CONCSUB {APPS username}/{APPS password} \
{responsibility application short name} \
{responsibility name} \
{username} \
[WAIT=N|Y{n seconds}] \
CONCURRENT \
{program application short name} \
{program name} \
[PROGRAM_NAME={description}] \
[REPEAT_TIME={resubmission time}] \
[REPEAT_INTERVAL= {number}] \
[REPEAT_INTERVAL_UNIT={resubmission unit}] \
[REPEAT_INTERVAL_TYPE={resubmission type}] \
[REPEAT_END={resubmission end date and time}] \
[START={date}] \
[IMPLICIT={ type of concurrent request} \
[{parameter 1} ... {parameter n}]

For parameters that follow the CONCURRENT parameter and include spaces, enclose the parameter argument in double quotes, then again in single quotes.

Monday, 6 May 2013

Shell Script Basic coding



 Enter the Name

echo "Enter The Name :"
read v_name
echo  $v_name

 Enter the name and Number
 

echo "Enter The Emp Name :"
echo "Enter The Emp Number:"
read v_name
read v_number
echo "Enter The Emp  Name"= $v_name
echo "Enter The Emp Number"= $v_number
  


Divide the value
echo "Enter the number :"
read v_num
echo "Enter the number1:"
read v_num1                               
v_sum=`expr $v_num /  $v_num1`
echo "Enter the number: " = $v_num
echo "Enter the number: " = $v_num1
echo "Sum of value: " = $v_sum

Inbount,Outbound Shell script

echo "Setting Parameters"
program=SHEll_PRO
userpass=`echo $1 | cut -f2 -d '"'`
user=`echo $userpass | cut -f1 -d '/'`
passwd=`echo $userpass | cut -f2 -d '/'`
reqid=`echo $1 | cut -f2 -d " " | cut -f2 -d "="`
usrid=`echo $1 | cut -f4 -d " " | cut -f2 -d "="`
################################
user_name=`sqlplus -s $userpass <<EXIT
set pages 0
set feed off
set verify off
select user_name from fnd_user where user_id=$usrid;
EXIT`
if  echo $user_name |grep "ORA-" > /dev/null
then
  echo "Error ... $user_name "
  exit 1
fi
echo user_name=$user_name
################################
get_directory_name()
{
sqlplus -s $userpass <<EXIT
set serverout on size 100000;
set pages 0
set feed off
set verify off
declare
l_err           varchar2(100);
l_name  varchar2(100);
Begin
mas_pa_bs_reverse_bill.get_dir_name('$file_lookup',l_name,l_err);
if l_err is not null then
   dbms_output.put_line('DIRECTORY_ERROR-'||l_err);
elsif l_name is null then
   dbms_output.put_line('Unable to get $file_type name');
else
   dbms_output.put_line(l_name);
end if;
end;
/
EXIT
}
################################
## ATT Location Address inbound directory is defined as NS_ATT_LOC_ADDR_IN
file_type='inbound directory'
file_lookup='AP_GTY_IN'
echo "Find $file_type name :lookup=$file_lookup"
inbound_dir=`get_directory_name`
if  echo $inbound_dir |grep "DIRECTORY_ERROR-" > /dev/null
then
  echo "Error ... $inbound_dir "
  exit 1
fi
echo inbound_dir=$inbound_dir
################################
## ATT Location Address error directory is defined as AP_GTY_ERR
file_type='inbound err directory'
file_lookup='AP_GTY_ERR'
echo "Find $file_type name :lookup=$file_lookup"
inbound_err_dir=`get_directory_name`
if  echo $inbound_err_dir |grep "DIRECTORY_ERROR-" > /dev/null
then
  echo "Error ... $inbound_err_dir "
  exit 1
fi
echo inbound_err_dir=$inbound_err_dir
################################
## ATT Location Address archive directory is defined as AP_GTY_ARCH
file_type='inbound archive directory'
file_lookup='AP_GTY_ARCH'
echo "Find $file_type name :lookup=$file_lookup"
inbound_arch_dir=`get_directory_name`
if  echo $inbound_arch_dir |grep "DIRECTORY_ERROR-" > /dev/null
then
  echo "Error ... $inbound_arch_dir "
  exit 1
fi
echo " start sqlload "
## SQLLDR SCRIPT
sqlldr $userpass control=$MAS_TOP/bin/TMS_TBL_CON.ctl data=$file.csv log=$inbound_dir/$file.log bad=$inbound_dir/$file.bad discard=$inbound_dir/$file.dis > $inbound_dir/sqlload_1 > $inbound_dir/sqlload_2
if [ ! $file.csv = $file_name ]
then
  mv $file.csv $file_name
fi

x=`date +"%m%d%y%H%M%S"`

echo " sqlload done, check for any errors"
if grep -i error $inbound_dir/sqlload_2 > /dev/null
then
     echo "********************************************************************************************************"
     echo "Error in Loading the file to the staging table for the file $file_name "
     echo "Error->$sqlload"
     echo "********************************************************************************************************"
     exit 1
elif [ -f $inbound_dir/$file.err ]
then
        echo "********************************************************************************************************"
      echo " *******  Error while Loading to the staging table for the file $file_name, please see the error file ******* "
        echo "********************************************************************************************************"
        echo "Moving the file $file_name to the error directory "
      mv $inbound_dir/$file_name $inbound_err_dir/$file_name.$x
fi
echo "Successfully loaded records from datafile $file_name"
echo
# Output Datafile row count
v_datafile_row_cnt=`wc -l $file_name | cut -f1 -d " " | tr -d " "`
v_datafile_row_cnt=`expr $v_datafile_row_cnt - 1`
echo "Moving data file $file_name to the Bank Reconciled Directory"
mv $inbound_dir/$file_name $inbound_arch_dir/$file_name.$x
echo " just sent the file: $inbound_dir/$file_name to $inbound_arch_dir/"
done
nil_report()
{
echo "No records to Process, exiting"
echo `date +"%r %a %d %h %Y " `  >> $repfile
echo "              No Files Found  " >> $repfile
echo "          ==============================================" >> $repfile
echo "        No records to Process" >> $repfile
}
echo " Bank Reconciled ended successfully"