How to read a parameter from properties file by shell script ?

I used ‘source’ syntax to called the parameter from property file.

1. create your directory on your linux OS environment.
– this <mydir> you need to change.

/<mydir>/call_dir/
call_dir.sh
/<mydir>/call_dir/config/
config.properties

/<mydir>/call_dir/logs/
log.txt

2. source bash file – ‘ call_dir.sh ‘

base_dir=/mydir/call_dir
config_dir=${base_dir}/config

# use source command to read the parameter key in properties
if [ -f ${config_dir}/config.properties ];then
source ${config_dir}/config.properties
else
MESSAGE=”Script END”
echo “$MESSAGE”
fi
echo “Log directory $LOG_DIR”

3. properties file config.properties
– values:
LOG_DIR=<mydir>/logs/logs.txt
Terima kasih,
Tubek blog ti…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s