[Solved] Unable to fetch the UNIX variable information

Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users [Solved] Unable to fetch the UNIX variable information
# 1  
Old 09-04-2013
RedHat [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…

And we are having another temporary parameter file abcd.txt, in that file we are having the following information like…

I am writing a shell script and using the abacd.txt file searching for EMAIL word and picking up the “EMAI_PATH”
Inside my I am executing variable_info.ksh script to fetch variable information.
Steps included in my scripts are..
./ variable_info.ksh
TMP_VAR_INFO=`grep “EMAIL” abcd.txt | cut –f1 –d”|”`

Then I am getting the “EMAI_PATH”
But I want to fetch the EMAIL_PATH information by looking abcd.txt file.
Whenever I do get the value of TMP_VAR_INFO= EMAI_PATH
I want to get the value as /var/mail.
Can you anyone please help me regarding this scenario.

Last edited by vbe; 09-04-2013 at 05:31 AM.. Reason: rm font tags +added code tags
# 2  
Old 09-04-2013
Dot the file instead of executing it

Replace ./ variable_info.ksh with . variable_info.ksh

This would ensure the variables exported in the variable_info.ksh file are available in the current shell.

If you execute the script then a sub shell is invoked and the parameters will be available only in the sub shell.
# 3  
Old 09-04-2013
I tried with that option and it's not working. Could you please suggest any other way i can achieve my result
# 4  
Old 09-04-2013
Please try this

. variable_info.ksh
TMP_VAR_INFO=$(grep "EMAIL" abcd.txt | cut -f2 -d"|")
eval echo \$${TMP_VAR_INFO}


# 5  
Old 09-04-2013
Thanks krishmaths Your solution worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Unable to fetch BIOS configuration details

Hi All, unable to fetch the bios configuration information and service provider information in centos 5 using dmidecode command. ServiceProvider=`dmidecode -s system-product-name |awk '{print $1}'` BIOS_Configuration=`dmidecode | grep "BIOS Information" -A10 | grep -e... (4 Replies)
Discussion started by: sravani25
4 Replies

2. Shell Programming and Scripting

Fetch field to variable

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. Shell Programming and Scripting

[Solved] Extracting information from DDL's

Dear Experts, I need your help here. I have lot of teradata DDL's as follows, i want to extract field names , field attributes and NOT NULL information from DDL.Could you please help here. Sample DDL: CREATE MULTISET TABLE APS_CALL_IN_PICKUP_CANCELED ,NO FALLBACK , NO BEFORE... (2 Replies)
Discussion started by: srikanth38
2 Replies

5. Shell Programming and Scripting

[Solved] How can I pull specific information from PS?

I need to grab information from the output of the ps command. For each line of ps output that contains _progres -b I need to get the word that follows -p. The "-p" can be anywhere after "_progres -b". Using grep to select the correct lines is no problem (e.g. ps -ef|grep "_progres \-b|grep -v... (3 Replies)
Discussion started by: Papa Lee
3 Replies

6. Shell Programming and Scripting

[SOLVED] UNIX FOR loop to read a variable with multiple values

Hi, I have a variable which stores file names as a result of find command. I need to delete all these files one by one, i.e. by a loop. Can anyone tell me how can it be done? The variable f2d has the file names like these abc.txt bcd.txt fff.txt gef.txt Now I have used a loop as... (12 Replies)
Discussion started by: jhilmil
12 Replies

7. Shell Programming and Scripting

Unable to fetch the output using AWK

Hi all, From the below file I need to fetch the data in the below output format. ToolInstanceID "diw_dm_sales" Identifier "Sales_source_load" Promt Default ParamType ParamLength ParamScale "Database_Name" "ORCL" "0" "0" "0" Identifier "retail_source_load" Promt Default... (4 Replies)
Discussion started by: onesuri
4 Replies

8. UNIX for Dummies Questions & Answers

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... (5 Replies)
Discussion started by: Swapna173
5 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