.id_pass_file.txt is a configuration file storing the password username ,sid and path of the shell script.i am just fetching the username ,password from them,.the cionnection is also successfull .But i dont understand the error that i am getting
Anyway, I've removed all the pointless cat's and replaced backticks with $() or removed pointless ones.
And added set -x for some trace. Please run it and post the output.
#!/bin/sh
set -vx
ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH
today=$(date "+%m-%d-%Y %H:%M:%S"); export today
CUR_DIR=$1; export CUR_DIR
LOG_FILE=$CUR_DIR/error.log; export LOG_FILE
# Direct script output to log
exec > $LOG_FILE 2>&1
echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=$(grep "^SCRIPT_DIR" $CUR_DIR/.id_pass_file.txt | cut -d "=" -f2)
export SCRIPT_DIR
### Credentials for SQLPLUS
USER_ID=$(grep "^USER_ID" $CUR_DIR/.id_pass_file.txt | cut -d "=" -f2)
export USER_ID
PWD=$(grep "^PWD" $CUR_DIR/.id_pass_file.txt | cut -d "=" -f2)
export PWD
SID=$(grep "^SID" $CUR_DIR/.id_pass_file.txt | cut -d "=" -f2)
export SID
### Connecting ORACLE
echo "SQLPLUS CONNECTION"
sqlplus -s $USER_ID@$SID/$PWD << EOF > $CUR_DIR/sql_output.txt
set feedback off
set heading off
select 1016 from adj where rownum <2;
EOF
if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi
##echo " The account numbers to be used in BIP are "
if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
while read LINE; do
echo "bip $i is running"
cd $SCRIPT_DIR
sh bip.sh 01 0 $i > $CUR_DIR/bip_log_1.txt ### Append to this one file, or a new file for each one?
sleep 100
done < $CUR_DIR/sql_output.txt
fi
###Removing temporary log files generated
if [ -f $CUR_DIR/bip_log_1.txt ]
then
rm $CUR_DIR/bip_log_1.txt
echo "file bip__log_1.txt removed"
fi
if [ -f $CUR_DIR/sql_output.txt ]
then
rm $CUR_DIR/sql_output.txt
echo "sql_output.txt removed"
fi
I didn't do anything here, except put the backticks back, and quote some variables.
#!/bin/sh
ORACLE_HOME=/var/opt/oracle/product/10g
export ORACLE_HOME
PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin
export PATH
today=`date "+%m-%d-%Y %H:%M:%S"`
export today
CUR_DIR=$1
export CUR_DIR
LOG_FILE="$CUR_DIR/error.log"
export LOG_FILE
# Direct script output to log
exec > $LOG_FILE 2>&1
echo
echo
echo "LOGGING STARTS $today"
echo
echo
###Fetching the script directory from configuration file
SCRIPT_DIR=`grep "^SCRIPT_DIR" "$CUR_DIR/.id_pass_file.txt" | cut -d "=" -f2`
export SCRIPT_DIR
### Credentials for SQLPLUS
USER_ID=`grep "^USER_ID" "$CUR_DIR/.id_pass_file.txt" | cut -d "=" -f2`
export USER_ID
PWD=`grep "^PWD" "$CUR_DIR/.id_pass_file.txt" | cut -d "=" -f2`
export PWD
SID=`grep "^SID" "$CUR_DIR/.id_pass_file.txt" | cut -d "=" -f2`
export SID
### Connecting ORACLE
echo "SQLPLUS CONNECTION"
sqlplus -s $USER_ID@$SID/$PWD << EOF > "$CUR_DIR/sql_output.txt"
set feedback off
set heading off
select 1016 from adj where rownum <2;
EOF
if [ $? -eq 0 ]
then
echo " SQLPLUS Connection Successful "
else
echo " SQLPLUS Connection Failed "
fi
##echo " The account numbers to be used in BIP are "
if [ ! -s "$CUR_DIR/sql_output.txt" ]
then
echo "No account number for bad debt"
else
while read LINE; do
echo "bip $i is running"
cd "$SCRIPT_DIR"
sh bip.sh 01 0 "$LINE" >> "$CUR_DIR/bip_log_1.txt" ### Append to this one file, or a new file for each one?
sleep 100
done < "$CUR_DIR/sql_output.txt"
fi
###Removing temporary log files generated
if [ -f "$CUR_DIR/bip_log_1.txt" ]
then
rm "$CUR_DIR/bip_log_1.txt"
echo "file bip__log_1.txt removed"
fi
if [ -f "$CUR_DIR/sql_output.txt" ]
then
rm "$CUR_DIR/sql_output.txt"
echo "sql_output.txt removed"
fi
Scott you are right and it is affecting my functionality too now
I am posting the BIP.SH
CODE
#!/bin/sh
ARBOR_DB_PASSWD=`cat $ARBORDIR/.arborpw`; export ARBOR_DB_PASSWD
DB_PASS=$ARBOR_DB_PASSWD; export DB_PASS;
ORACLE_SID=$ARBOR_CATALOG_DATABASE; export ORACLE_SID;
ARBORCTRLRPT03=$ARBORDATA/reports/ctrl; export ARBORCTRLRPT03;
Usage(){
echo "\n\n Usage is: `basename $0` <proc_num> <bip mode> <account_no>\n"
echo " where <proc_num> is a number between 01 and 99"
echo " <bip_mode> is a number. Use 0=production, 3=proforma, 6=backout"
echo " <bip_mode> is an arbor accout number\n\n"
exit 0
}
# Check number of arguments
if [ "$#" -ne 3 ] ; then
Usage
fi
# Check to see if ARBORDBU is set
if [ -z "${ARBORDBU}" ] ; then
echo "ERROR: \$ARBORDBU environment variable is not set\n"
echo "This script requires that the \$ARBORDBU environment variable be set.\n\n"
exit 1
fi
# Check to see if DB_PASS is set
if [ -z "${DB_PASS}" ] ; then
echo "ERROR: \$DB_PASS environment variable is not set\n"
echo "This script requires that the \$DB_PASS environment variable be set.\n\n"
exit 1
fi
# Check to see if ORACLE_SID is set
if [ -z "${ORACLE_SID}" ] ; then
echo "ERROR: \$ORACLE_SID environment variable is not set\n"
echo "This script requires that the \$ORACLE_SID environment variable be set.\n\n"
exit 1
fi
# Set the variables for arguments passed by the user
PROCNAME=bip$1
BIP_MODE=$2
ACCOUNT=$3
# Get the database from the user's environment
DB=$ORACLE_SID
# Set this so that the process doesn't try to connect to Operations Center
OAM_ENV_CONN_MA=FALSE
export OAM_ENV_CONN_MA
# Log into sqlplus, delete any existing entries, and make the new entry
sqlplus -s $ARBORDBU/$DB_PASS@$DB <<END
update SYSTEM_PARAMETERS set int_value=1 where module='BIP' and parameter_name='TRA_SWITCH';
delete from PROCESS_SCHED where process_name = '$PROCNAME';
delete from PROCESS_STATUS where process_name = '$PROCNAME';
insert into PROCESS_SCHED values('$PROCNAME','$PROCNAME','N',$BIP_MODE,SYSDATE,86400,0,2,55,'$DB','CMF.account_no in ($ACCOUNT)',1,NULL,0,NULL,0);
commit;
exit
END
echo "Starting BIP in the background with process name = \"$PROCNAME\""
BIP $PROCNAME 3 &
Please tell what should i modify.I cant change the bip.sh