fetch Variable value


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers fetch Variable value
# 1  
Old 09-30-2008
fetch Variable value

Hi Guys,

I have written a script that declares all the variables and its values in a conf file.
Now i use a variable whose value i need to change it in one of the sub-file that is used in the script.

In the startup file i want to print or check its value.
The value get changed and printed properly in the sub-file but in the startup file at the end it displays the value in the conf file which has all the variables declared.

how can i fetch the last updated value of that variable.

Swapna
# 2  
Old 09-30-2008
Best post your script so we see what you do. Also use [ code ] and [ /code ] tags please.
# 3  
Old 09-30-2008
------------------------
contents in conf file utilityenv.conf
------------------------

export DataLoadedSummaryFile=Load_Measure_Summary.tab
export TOTALETLFILES=7
export ETLFILESFOUND=0

-------------------------------------
Startup File contents ETL_Monthly.sh
-------------------------------------
. ~/.bashrc
SetTkEnv 2>/dev/null

#This File contains all the variables used in the ETL Process
. ./utilityenv.conf
#Process 5
#This File Loads the Actual Measure Data in the Staging Database User From the Source Files received
bash $CommandFiles/Load_Measure_Data_In_Staging.sh
Status=$?

mailsubject="ETL Process - Success"
echo "" > $ETL_HOME_DIR/mailbody.txt
echo "ETL Files found : " $ETLFILESFOUND
echo "Total ETL Files : " $TOTALETLFILES
if [ $ETLFILESFOUND -eq $TOTALETLFILES ]
then
echo "ETL process completed successfully." >> $ETL_HOME_DIR/mailbody.txt
else
echo "ETL process partially completed." >> $ETL_HOME_DIR/mailbody.txt
fi
echo "<BR><BR>" >> $ETL_HOME_DIR/mailbody.txt

-------------------------------------------------------
sub-file Load_Measure_Data_In_Staging.sh contents
-------------------------------------------------------
bash utilityenv.conf
if [ $filecount -gt 1 ] #Check for more than one dat files exist for a single control file
then
echo "set source_file_count = -1 " >> $SqlFiles/update_configuration_master.sql
elif test -f $datfile #Check file exist
then
ETLFILESFOUND=`expr $ETLFILESFOUND + 1`
echo "ETL files found : " $ETLFILESFOUND
loadtype=`echo $datfile | tr "_" "\n" | tail -1 | cut -d"." -f1`

filedatacount=`cat $datfile | wc -l`
#filedatacount=`cat $datfile | cut -sd "," -f13 | sed -e '/^$/ d' | wc -l`
fi
# 4  
Old 09-30-2008
You should use "source" (dot) instead of "bash" if you want ETLFILESFOUND and TOTALETLFILES to be visible in the calling script.
# 5  
Old 09-30-2008
but will i be able to change its value in the sub-file Load_Measure_Data_In_Staging.sh
and retrieve the same
# 6  
Old 09-30-2008
If I understand your question correctly, then yes (and you should be able to trivially try it and see what happens).
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

To Fetch values from String

Dears, I have string like below in my csv file <someTechnicalDetails><someTechnicalDetails>HSI</someTechnicalDetails,1234564 <someTechnicalDetails><someTechnicalDetails>Voice</someTechnicalDeta,12345673 <someTechnicalDetails><someTechnicalDetails>IPTV</someTechnicalDetai,12345673 and I... (2 Replies)
Discussion started by: mirwasim
2 Replies

2. Shell Programming and Scripting

Fetch field to variable

Input.txt NOTE1|VALUE1|HMM|UPSTR| NOTE2||HMP|UPSTR| NOTE3|VALUE3|HML|UPSTR| NOTE4||HMD|UPSTR| NOTE5|VALUE5|HMS|UPSTR| NOTE6|VALUE6|HSD|UPSTR| NOTE7||HSS|UPSTR| NOTE8|VALUE8|HEE|UPSTR| NOTE9|VALUE9|HER|DOWNSTR| NOTE50|VALUE1|HEE|DOWNSTR| I am trying to read field 1, 2 and 3 from the... (4 Replies)
Discussion started by: Joselouis
4 Replies

3. Shell Programming and Scripting

Scirpt to fetch the variable from sqlplus

Hi Gurus, I am stuck with the step where i need to fetch the location & sales from the below procedure by taking it from table field using the for loop. any idea how this can be done in unix. From one column both the location and sales are taken out. create or replace procedure newyork... (2 Replies)
Discussion started by: arun888
2 Replies

4. UNIX for Advanced & Expert Users

[Solved] Unable to fetch the UNIX variable information

I am having a file called variable_info.ksh in that file I am having following global variable information like… EMAIL_PATH=/var/mail TMP_PATH=/home/tmp And we are having another temporary parameter file abcd.txt, in that file we are having the following information like… EMAIL|EMAI_PATH I... (4 Replies)
Discussion started by: mesahammad
4 Replies

5. Shell Programming and Scripting

Fetch the value from Here Document

I have code like var="1" echo << EOF export `var="2"` EOF echo $var The value of var is printed here is 1 but it should be 2 Any error there? ---------- Post updated at 11:44 AM ---------- Previous update was at 10:33 AM ---------- Also tried var="1" echo var << EOF echo... (1 Reply)
Discussion started by: adisky123
1 Replies

6. Shell Programming and Scripting

Fetch the different data by searching with a same variable from a file in AIX server

Hi, I am trying to fetch the different values in an xml file by searching with the same variable in AIX Server. <name>SharedResources/Shared/JNDI/Username</name> <value>admin</value> <name>SharedResources/Shared/JNDI/Username</name> ... (1 Reply)
Discussion started by: tejastrikez
1 Replies

7. Shell Programming and Scripting

Fetch PID

Hi All, i get this output when i do PS UX tdntp 9263 0.0 0.0 98464 3200 pts/1 S+ 14:16 0:00 vim FAB1_600015_CONRAD.A0_7XYZ12345.000_LT-SWET.01_LTPA25L_ I want to get the PID of certain specefic filename. so i tried ps ux | pgrep... (13 Replies)
Discussion started by: asheshrocky
13 Replies

8. HP-UX

how to fetch idle time

HP-UX B.11.23 ia64 Hi everyone, First of all I am new member to this forum. Thankyou all for this forum, it helped me many times. Coming to my question,I am writing a C program to find the log info of the users who are currently logged in(precisely what who -u do). I am able to get... (0 Replies)
Discussion started by: bhiku matre
0 Replies

9. Shell Programming and Scripting

How to fetch variable value in if block and to compare it with certain string

Hi, I am trying to execute this command if ; then but getting error .Some problem with reteriving the value of $exception_info. Please help.Its urgent. thanks (4 Replies)
Discussion started by: khushboo
4 Replies

10. Shell Programming and Scripting

Unix code to fetch the first field till space in a variable

Hi, I want to get the value of the first field till space in a variable. e.g x=323 /test/personel/logs/File1 I want to get the first field till space i.e 323 in another variable ,lets say y. echo $x|cut -d' ' -f1 gives 323 but when I'm trying y=`echo $x|cut -d' ' -f1 its giving... (3 Replies)
Discussion started by: autosys_nm
3 Replies
Login or Register to Ask a Question