LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-05-2011, 12:36 AM   #1
sukhdip
Member
 
Registered: Sep 2011
Posts: 54

Rep: Reputation: Disabled
Reading a property file through shell script???


Hi!
i need a script that can read a property file.
i.e., A script to read a "property" from property file.
Read the property value and
based on value of property, decide whether to start the some dataload activity or not.

Its urngent. Can anyone help me out???
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 10-05-2011, 01:19 AM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
Hello,

This makes no sense to me whatsoever. What exactly are you trying to do here? And what property file are you talking about? Also, what is this "dataload activity" you are talking about?

Cheers,

Josh
 
Old 10-05-2011, 01:59 AM   #3
sukhdip
Member
 
Registered: Sep 2011
Posts: 54

Original Poster
Rep: Reputation: Disabled
Hey! its kind database activity in IBM WCS.

There are java properties files which are having key and action related to that.(For example am attaching a property file,its like text file can open with notepad)

Here is the problm: Script should read that property file and if the value of property file is YES, then it should start the activity of dataload.or more precisly its should return YES valuse to crontab which will start the dataload, which i will configure in crontab.
If property file value is NO. then not to start dataload.

If you understand n how much u understand. then please help me out.


Please remove txt from extension as to get properties file.
Attached Files
File Type: txt example.properties.txt (97 Bytes, 366 views)
 
Old 10-05-2011, 02:07 AM   #4
sukhdip
Member
 
Registered: Sep 2011
Posts: 54

Original Poster
Rep: Reputation: Disabled
Or can you please provide me a script that will read a prorperty file.....???
Just to read property file.
 
Old 10-05-2011, 02:27 AM   #5
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi

If you have a file with 'example' contents:
Code:
#
# these all are the comments as per file.
# Property File
#

DATA_LOAD=YES
then you can get the value from file like:
Code:
# grep -i 'DATA_LOAD' example.properties.txt  | cut -f2 -d'='


Output:
YES
or in script ( let's call it "testproperty.sh":
Code:
#!/bin/sh
FILE=/var/tmp/testproperties/example.properties.txt

ACTION=$(grep -i 'DATA_LOAD' $FILE  | cut -f2 -d'=')

if [ "$ACTION" = "YES" ]
then

... do something you need to when answer is Yes ...

elif [ "$ACTION" = "NO" ]
then

... action to take if No ...
# for example print out the value
echo "$ACTION"

# if no match
else 
echo "$ACTION"

fi
#end of script
This script assumes that you have only one ( 1) line with:
Code:
DATA_LOAD=YES
or DATA_LOAD=NO

Last edited by lithos; 10-05-2011 at 02:35 AM.
 
2 members found this post helpful.
Old 10-05-2011, 04:05 AM   #6
sukhdip
Member
 
Registered: Sep 2011
Posts: 54

Original Poster
Rep: Reputation: Disabled
lithos you rocks buddy!!
 
Old 10-05-2011, 09:07 AM   #7
sukhdip
Member
 
Registered: Sep 2011
Posts: 54

Original Poster
Rep: Reputation: Disabled
Hi!

Like I have to run a batch file named dataload.bat.. which will perform further actions of loading data. which might be scheduled in crontab to run.
what i should use or how i should make use of this script that will run that crontab or dataload.bat file if and only if the status of property file is YES. I have to put that under If condtion..right..
coz just new to this scripting i dn't know much about it.

So please guide me..

Thanks,
 
Old 10-05-2011, 09:31 AM   #8
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
well, since I don't know IBM WCS system I can only assume that "dataload.bat" is for Windows, which I'm not familiar with scripting, only Linux.

but anyway, you can insert the line to 'run' your script into the code "testproperty.sh":
Code:
#!/bin/sh
FILE=/var/tmp/testproperties/example.properties.txt

ACTION=$(grep -i 'DATA_LOAD' $FILE  | cut -f2 -d'=')

if [ "$ACTION" = "YES" ]
then
# here you run your script
$(/path/to/your_script/dataload.bat)

elif [ "$ACTION" = "NO" ]
then

... action to take if No ...
# for example print out the value
echo "$ACTION"

# if no match
else 
echo "$ACTION"

fi
#end of script
and CRONTAB is not meant to be run by script, that's why it's scheduled running.

You will do best if this script is running with Crontab and inside this script you call the "dataload.bat" like posted above.

Last edited by lithos; 10-05-2011 at 09:39 AM.
 
Old 10-05-2011, 09:50 AM   #9
nandi
LQ Newbie
 
Registered: Oct 2011
Posts: 7

Rep: Reputation: Disabled
Thanks a lot for your valuable reply. I will let you know after running this system.

Yeah at last I'm going to run the whole things on AIX.

I will post here by tomorrow.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to install software package using shell script +property file..... badmas Linux - Newbie 3 04-16-2011 02:12 AM
Reading a .CSV file and then calculating average per minute basis in shell script. krishdeeps Linux - Newbie 1 04-23-2010 04:38 PM
Shell script:- Reading numbers embedded in brackets from a text file rsan Linux - Newbie 6 07-05-2009 06:01 AM
SHell Script Help! When reading input from a user sfmadmax Linux - Newbie 3 12-12-2007 12:03 AM
shell script for reading of configuration files nhydra Programming 2 06-13-2006 03:15 AM


All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration