Fetching variable from config file

I am using . .profile in my script below
I want to fech it it from my configuration file .id_pass_file.txt(it has all user_name and passwords)
how can i do this

PROFILE_PATH=. .profile
AND IN MY SCRIPT 
$PROFILE_PATH
IS THIS CORRECT
#!/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

## /path/to/profile .This is required for crontab to work as bip.sh  uses environmental variables.
. .profile

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=`cat $CUR_DIR/.id_pass_file.txt | grep "^SCRIPT_DIR" | cut -d "=" -f2`; export SCRIPT_DIR

### Credentials for SQLPLUS

USER_ID=`cat $CUR_DIR/.id_pass_file.txt | grep "^USER_ID" | cut -d "=" -f2`; export USER_ID
PWD=`cat $CUR_DIR/.id_pass_file.txt | grep "^PWD" | cut -d "=" -f2`; export PWD
SID=`cat $CUR_DIR/.id_pass_file.txt | grep "^SID" | 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 distinct account_no from adj  WHERE ADJ_TRANS_CODE=-2401  and request_status=1  and bill_ref_no=0
order by account_no;
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
for i in `cat $CUR_DIR/sql_output.txt`
do
echo "bip $i is running"
sh  $SCRIPT_DIR/bip.sh 01 0 $i >  $CUR_DIR/bip_log_1.txt
sleep 180
done
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

rm  $CUR_DIR/error.log

You may need to fully qualify the path the your .profile. Consider also that the default path created by logging on may be different to that created by a cron job.

I would also quote the value if you are going to set PROFILE_PATH:-

PROFILE_PATH=". /home/myuser/.profile"

Do either of these suggestions help?

Robin
Liverpool/Blackburn
UK

Hi i can see two profile paths
locations are

/.profile

and

echo  $HOME/.profile
/A/B/.profile

Which profile to use .Please enlighten me.My script is working fine for /.profile

I would assume that /.profile is going to be the profile for the root user (and any other user that has home directory of /

You may not be able to use the value from $HOME in your cron job though.

Robin

So you mean i should use /.profile.i am in DEV enviroment .Hope it works in production too:eek:

i followed your advice
PROFILE_PATH="/.profile"
But i am getting an error
/.profile not found
PROFILE_PATH=/.profile --this works fine though

rbatte please reply lol

Is .profile in /, yes or no? If not, it won't find it there, you'll need to tell it somewhere else.

In dev enviroment it is there.In production i dont know .Thats is my i am storing it in the configuration file.i will tell them to change it.

Do you not want to source/include the appropriate .profile though? You need to have:-

PROFILE_PATH=". /dir/.profile"

... if you want to just execute:-

$PROFILE_PATH

... in your script.

You need to check that the account running the script through cron has read permission on whichever .profile you choose to run. Perhaps you should create your owner environment script, e.g. /usr/local/bin/my_env.sh

Robin

I want to give the absolute path of .profile
My absolute path is /.profile.So i am using
PROFILE_PATH=/.profile
But you are telling to use like this
PROFILE_PATH="/.profile"
It is throwing an error.
I can't create my own .profile in PRODUCTION .So i should avoid that