parameters file


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users parameters file
# 1  
Old 02-25-2011
parameters file

Hi,
on AIX 6.1

I have a shell script that calls another shell which have some parameters. Say like the following :
Code:
##This is main script############
myparameters.sh
command1
command2
.....
....

And here myparameteres.sh :

Code:
export ORACLE_SID=MYDB
export mydir='/appli/oracle/BACKUP/RMAN/INCR/$ORACLE_SID'
export user=rmanuser

The problem is that after comming back to the main script the parameteres have lost their values :

echo $ORACLE_SID
ANOTHERDB

How can I resolve this ??
Thank you.
# 2  
Old 02-25-2011
In sh/ksh/bash... you 'source' your parameter file like so:
Code:
##This is main script############
. myparameters.sh
command1
command2
.....
....

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 02-26-2011
realy thank you.

I call myparameters.sh script :
. myparameters.sh abcd

And then in myparameters.sh, I set a parameter like this :
Code:
export mydir='/appli/oracle/BACKUP/RMAN/$1/$ORACLE_SID'

But the result is :
Code:
echo $mydir

/appli/oracle/BACKUP/RMAN/$1/$ORACLE_SID

ORACLE_SID is set (exported) in main script.

thanks for help.
# 4  
Old 02-26-2011
Code:
export mydir="/appli/oracle/BACKUP/RMAN/$1/$ORACLE_SID"

# 5  
Old 02-26-2011
thank you.
It's ok.
# 6  
Old 02-26-2011
Isn't $1 just the first parameter? You're not giving it any parameters when you source it, so $1 will be blank at best.
# 7  
Old 02-26-2011
Quote:
Originally Posted by Corona688
Isn't $1 just the first parameter? You're not giving it any parameters when you source it, so $1 will be blank at best.
yes, he/she is:
Code:
. myparameters.sh abcd

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating a config file with specified parameters

I want to create a config file that has parameters that can be specified using - or -- (without an equals sign), as well as the ability to output the file using - or --. Could somebody point me to a generic script to do this? Say for example, I wanted to run MainScript and have it set alpha to 2... (1 Reply)
Discussion started by: multiverse22
1 Replies

2. Shell Programming and Scripting

Help with passing parameters from a file

Hello Everyone, I have developed a shell script which takes schema id and password as parameter to login into database using sqlplus,runs a query and mails the result. My requirement is that, I dont want to pass userid and password as parameters.Instead,I want to pass say Environment... (4 Replies)
Discussion started by: karthik adiga
4 Replies

3. Shell Programming and Scripting

Shell Script to Dynamically Extract file content based on Parameters from a pdf file

Hi Guru's, I am new to shell scripting. I have a unique requirement: The system generates a single pdf(/tmp/ABC.pdf) file with Invoices for Multiple Customers, the format is something like this: Page1 >> Customer 1 >>Invoice1 + invoice 2 >> Page1 end Page2 >> Customer 2 >>Invoice 3 + Invoice 4... (3 Replies)
Discussion started by: DIps
3 Replies

4. Shell Programming and Scripting

Run a program-print parameters to output file-replace op file contents with max 4th col

Hi Friends, This is the only solution to my task. So, any help is highly appreciated. I have a file cat input1.bed chr1 100 200 abc chr1 120 300 def chr1 145 226 ghi chr2 567 600 unix Now, I have another file by name input2.bed (This file is a binary file not readable by the... (7 Replies)
Discussion started by: jacobs.smith
7 Replies

5. Shell Programming and Scripting

Help in reading parameters from file

Hi guys, I have a parameter file in the below format. BatchTrkId=102 BusinessUnit=GMUS Country=US I want to assingn each of them to a separate variables so that they can be used below in the script. Can somebody help me out here. Cheers!!!! (4 Replies)
Discussion started by: mac4rfree
4 Replies

6. UNIX for Dummies Questions & Answers

Passing the parameters through a file

Hi All, I have written a shell script and the script is working fine, I am passing my MIT_ID(NUMBER VALUE) to the shell script from the command prompt and my script is executing as expected. Now I have to pass all the MIT_ID's from a .txt file to the shell script,as I am automating this I... (6 Replies)
Discussion started by: gaur.deepti
6 Replies

7. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

8. Shell Programming and Scripting

Read parameters from a file

Hello all, I need to extract parameters from a file. For example, I have a file file.dat as par1 val1 par2 val2 par3 val3 I need to extract this and store val1 in par1 variable and so on. Please help. Thanks for your support. (2 Replies)
Discussion started by: cheerful
2 Replies

9. Shell Programming and Scripting

read parameters from file

Hi there, I'm wondering how I can run a script that would loop and launch a command that would take as parameter every line in a file one by one. For example, say I want to remove a list of files: ~$ cat filestoremove foo bar ~$ cat myscript for file in filestoremove; do rm $file... (2 Replies)
Discussion started by: chebarbudo
2 Replies

10. Shell Programming and Scripting

Passing parameters through a file

I have created a script "myscript.sh" I need to run this script with diffrent parameters. The parameters are stored in a file myparam.txt. I need to run myscript.sh script for every parameter supplied in myparam.txt. Example: If myparam.txt contains following lines: param1 param2 param3... (3 Replies)
Discussion started by: chawlaaman
3 Replies
Login or Register to Ask a Question