Help with loading config files


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Help with loading config files
# 1  
Old 04-17-2011
Data Help with loading config files

Hi All,

I'm bit confused with a script
Any help would be appreciated

I have a config file say config.cfg and iam loading config file in My_Script.sh..The script name is My_Script.sh.
My_Script.sh and config.cfg are in same directory...My_Script.sh is run on the crontab
Code:
50 01 * * * [ -f /home/k7/My_Script.sh ] && cd /data2/log/bin/oapi; ./My_Script.sh -t weekly > /dev/null 2>&1

The contents of config.cfg is
Code:
OUTPUT_FILE=/home/k7/final_output.csv

and the contents of My_Script is
Code:
#!/bin/sh
....
....
USAGE="USAGE: $0 -t weekly|monthly\n"
....
....
....
$CONFIG_FILE=./config.cfg

. $CONFIG_FILE #Loading config file

if [ $? -ne 0 ]
then
    echo "Error while loading $CONFIG_FILE config file"
    exit 1
fi

...
...
...

set -- `getopt t: $*`
if [ $? -ne 0 ]
then
    echo $USAGE
    exit 1
fi

1)In this code
Code:
if [ $? -ne 0 ]
then
    echo "Error while loading $CONFIG_FILE config file"
    exit 1
fi

what does if [ $? -ne 0 ] condition signify.I mean what is "$?" implies...


2)what the below two code implies
1st code
Code:
set -- `getopt t: $*`
if [ $? -ne 0 ]
then
    echo $USAGE
    exit 1
fi

2nd code
Code:
50 01 * * * [ -f /home/k7/My_Script.sh ] && cd /data2/log/bin/oapi; ./My_Script.sh -t weekly > /dev/null 2>&1

Thanks in advance

Last edited by Scott; 04-17-2011 at 02:51 PM.. Reason: Code tags, please...
# 2  
Old 04-17-2011
1-) $? , tells us that last command exit status code..usually success commands returns 0 , if fails return codes nonzero value.

2-) set -- `getopt t: $*` , makes the positional parameters set to the " -t plus $* plus --" ,
so if you run this like -- > ./My_Script.sh -t weekly --> positonol paramertes equals to " -t weekly -- "
if you run this like -> --> ./My_Script.sh -t weekly monthly --> positonol paramertes equals to " -t weekly -- monthly "

but in this case as if , set -- `getopt t: $*` always returns zero.Smilie

3-) 50 01 * * * [ -f /home/k7/My_Script.sh ] && cd /data2/log/bin/oapi; ./My_Script.sh -t weekly > /dev/null 2>&1
this script will run every day every at 01:50.
if "/home/k7/My_Script.sh" file is exist and regular file then run these commands
" cd /data2/log/bin/oapi; ./My_Script.sh -t weekly "
if "/home/k7/My_Script.sh" file is not exist or is not regular file then runs this command
./My_Script.sh -t weekly

if you write full script , we can maybe more help..Smilie


regards
ygemici
# 3  
Old 04-17-2011
Since you didn't take the hint last time:

PMING PEOPLE WITH TECH SUPPORT QUESTIONS IS COMPLETELY AGAINST THE RULES.

IT IS ALSO RUDE.

IT DOESN'T GET ME HERE ANY FASTER. NOBODY HERE IS "ON CALL".

STOP DOING IT!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Windows & DOS: Issues & Discussions

(VS 2008) New build config looking files from other folder build config

Hi Team, My new build configuration always looking for the files from the build where i copied from. please help me to resolve this. I am using Visual studio 2008.It has Qt 4.8. plugins,qml,C++ development I created new debug_new build configuration with additional preprocessor from the... (1 Reply)
Discussion started by: SA_Palani
1 Replies

2. Shell Programming and Scripting

Need some help on scripting for validating the files before loading

Hi, I need to perform some validation steps on the files before I start loading them. 1. I need to check for the availabilty of the file in expected path with expected name. 2. I need to check If the file format is correct. a. confirm if correct delimiter is used. b.... (1 Reply)
Discussion started by: smileyreddy
1 Replies

3. Shell Programming and Scripting

What's the best way to read config files?

(copied directly from my other thread about something else) At the moment, I just use... cat config_file|grep var_name|cut -d'=' -f2 ... which is fine for what I've been doing, but I'm not sure what to do when there are a variable number of entries and I want it go through them like a... (7 Replies)
Discussion started by: ninjaaron
7 Replies

4. UNIX for Advanced & Expert Users

Loading files incrementaly

Hi Am trying to sftp this way UnixBoxA----->UnixBoxB My code will run on UnixBoxB, it will make a secure connection and pull the files from UnixBoxA. Apart from that I do not have any access on UnixBoxA Now UnixBoxA will receive the files daily, the file format will be... (0 Replies)
Discussion started by: hemanty4u
0 Replies

5. Shell Programming and Scripting

Shell script that will compare two config files and produce 2 outputs 1)actual config file 2)report

Hi I am new to shell scripting. There is a requirement to write a shell script to meet follwing needs.Prompt reply shall be highly appreciated. script that will compare two config files and produce 2 outputs - actual config file and a report indicating changes made. OS :Susi linux ver 10.3. ... (4 Replies)
Discussion started by: muraliinfy04
4 Replies

6. Shell Programming and Scripting

parsing config file to create new config files

Hi, I want to use a config file as the base file and parse over the values of country and city parameters in the config file and generate separate config files as explained below. I will be using the config file as mentioned below: (config.txt) country:a,b city:1,2 type:b1... (1 Reply)
Discussion started by: clazzic
1 Replies

7. Shell Programming and Scripting

loading Binary files with SQLLDR

Hi, Can anyonr please tell how to load a binary file through SQLLDR. I have the structure of the binary file in a seperate lb file but I don't know how to feed it to the sqlldr. (0 Replies)
Discussion started by: snowline84
0 Replies

8. Shell Programming and Scripting

Function loading in a shell scripting like class loading in java

Like class loader in java, can we make a function loader in shell script, for this can someone throw some light on how internally bash runs a shell script , what happenes in runtime ... thanks in advance.. (1 Reply)
Discussion started by: mpsc_sela
1 Replies

9. HP-UX

Config Files

Does anyone have a list of key config files and the respective paths for HP-UX? Or does anyone know where I can get a list similar to this? Thanks, TOdd (0 Replies)
Discussion started by: toddjameslane
0 Replies
Login or Register to Ask a Question