enhanced substitution

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting enhanced substitution
# 1  
Old 10-24-2009
enhanced substitution


I have a problem on which I turn araound since hours.
Hope you could help me.

I have a bash script, which activates with "nohup ./script2 params & " several subscripts.

In my main script, I have set lot's of variables, which I would pass into script 2.

My idea is now to create a file with parameter content, like:

Then I just pass over this parameter path & filename and execute it then in the subscripts.

So far this works well.

Here my questions:
1) Is there a possibility to create the parameter file more dynamically, e.g. by all parameters defined in main script when parameter file is created ? (like env but for script variables only..)

2) When I have a list of variable names I want to pass, how could I dynamically fill the parameter file.
cat my_file_with_parameternames.txt

echo $envCode

echo $envPath

for k in `cat my_file_with_parameternames.txt`
    echo $k=<value of $k variable>"  >> my_parameter_file.sh

cat my_parameter_file.sh

Maybe it's not the first time this question is asked, but to be honest, I'm google since hours... Most probably I do not know the correct words to search for ;-(

Any help would be great.

many thanks in advance
# 2  
Old 10-24-2009
If I understand you correctly, all you have to do is export the variables in the main script.
The variable will be defined in all shell scripts you call from the main script.

For example, to make envCode available to the subscripts put this near the beginning of the main script.

export envCode

# 3  
Old 10-24-2009
eval echo "$k=\$$k"  >> my_parameter_file.sh

if you want double quotes around the values in the parameter file then you can used this:
eval echo "$k=\\\"\$$k\\\"" >> my_parameter_file.sh

Last edited by Scrutinizer; 10-24-2009 at 07:58 AM..
# 4  
Old 10-24-2009
Originally Posted by Scrutinizer
eval echo "$k=\$$k"  >> my_parameter_file.sh

Yep. That's it.

Thanks a lot.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

New Enhanced Forum Features for VIP Members

Dear All, Thank you for your support. As promised I have upgrade features for unix.com forum VIP members as follows: Who's Online Permissions Can View IP Addresses Can View Detailed Location Info for Users Can View Detailed Location Info of Users Who Visit Bad / No Permission... (0 Replies)
Discussion started by: Neo
0 Replies

2. AIX

Normal VG to Enhanced Concurrent VG

Hi All, I am going to perform some activity in 2Node HA Server(Active/Passive). For that i have to do some pre-requsite (ie., Resource Group VG's should be Enhanced-Concurrent) In my setup, we have two volume groups in one RG. In that one VG is Normal and another is Enhance Concurrent. ... (2 Replies)
Discussion started by: Thala
2 Replies

3. UNIX for Dummies Questions & Answers

Convergent Enhanced Ethernet

Hi. I guess this my dummy question is for super-gurus. I'm on Red Hat' documentation regarding their RDMA capabilities over "convergent" Ethernet network. I read everything that I could find on inet, wikipedia etc. about the technology itself. I can't figure out, how can I determine if the... (0 Replies)
Discussion started by: newlinuxuser1
0 Replies

4. IP Networking

enhanced tcpdump is needed

Are there any standard programs in linux/unix like tcpdump that store packets' headers in db (Berkeley DB is preffered, including secondary db's to index stored headers by IP addesses, TCP flows, etc.), provide search in db and convert found headers to tcpdump dumpfile format? (12 Replies)
Discussion started by: Hitori
12 Replies

5. UNIX for Advanced & Expert Users

Are there many UNIX server security enhanced products?

for sco, hp, or AIX...... anyway, how can I secure the UNIX system. I knew that CA has it's products for securing the UNIX server system. Please tell me more about other vender, and their products thxs! (0 Replies)
Discussion started by: brookwk
0 Replies

6. Solaris

Enhanced Password Authentication

Hello; I am moving a customer from Solaris 2.6 to Solaris 2.8. The customer has requested the following two requirements also be implemented: 1. Lock a user account out for X number of days after 3 unsuccessful login attempts. 2. No reuse of the last 5-10 passwords. Also referred to... (1 Reply)
Discussion started by: rambo15
1 Replies

7. UNIX for Advanced & Expert Users

C2 or enhanced security

We are using c2 / enhanced security on digital unix. I do not have access to the GUI. I need to get information on login status for users. Specifically I would like to know who has not logged in within the last 6 months. I think I can query the edauth files, but I can't find information on... (4 Replies)
Discussion started by: MizzGail
4 Replies
Login or Register to Ask a Question