Read parameter file for a shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Read parameter file for a shell script
# 1  
Old 10-16-2013
Read parameter file for a shell script

Hi All,

I need urgent Help from all of you here.
Below is my code-
==================================================
Code:
#!/usr/bin/sh
cd $1
cat $2 | tr -ds "$" "" > parameter_file.param
export `parameter_file.param`
chmod 777 parameter_file.param
echo $1
echo $2
cd $prmDirInput
infile=$prmDirInput/$3
filecount=`wc -l $infile`
echo $filecount
echo $prmDirInput

================================================

I'm running this code by script-
Code:
./check_test.sh Parameter_file_path parameter_file FileName

When I'm running my script it is not taking values present in my parameter file. I don't know why it is doing this
can somebody plss help?

Last edited by Franklin52; 10-16-2013 at 10:27 AM.. Reason: Please use code tags for data and code samples
# 2  
Old 10-16-2013
Could you show us the contend of parameter_file ?
# 3  
Old 10-16-2013
Code:
$ cat dsquestnet.param
$prmDirInput=/dstage/questnet/qnetdv/input
$prmDirScripts=/dstage/questnet/qnetdv/scripts
$prmDirOutput=/dstage/questnet/qnetdv/output
$prmDirStage=/dstage/questnet/qnetdv/stage


Last edited by Franklin52; 10-16-2013 at 10:28 AM.. Reason: Code tags
# 4  
Old 10-16-2013
A file that contains environment variable should be loaded that way (in bash|ksh|sh):
<dot> <space> <filename>
where <filename> could be relative or absolute (specifying the full PATH)
Code:
. ./yourfile.env


in csh :
Code:
source ./yourfile.env


so instead of
Code:
export `parameter_file.param`


use
Code:
. ./parameter_file.param

By the way, setting chmod 777 on a file is NOT a good idea from a security point of view :
Here, that would allow any user to modify the parameters you load ...

Last edited by ctsgnb; 10-16-2013 at 04:56 AM..
# 5  
Old 10-16-2013
Let me know if I'm wrong??
As per your comment.. Instead on passing $1 and $2, I can read parameter file using

. /parameter_path/dsquestnet.param
# 6  
Old 10-16-2013
A short example is often better than a long story :

Code:
$ cat myenv
myvar=tst
anyvar=anyvalue
however=whatever
$ echo :$myvar:$anyvar:$however:
::::
$ . ./myenv
$ echo :$myvar:$anyvar:$however:
:tst:anyvalue:whatever:
$

---------- Post updated at 10:40 ---------- Previous update was at 10:37 ----------

Quote:
Originally Posted by Amit786
Let me know if I'm wrong??
As per your comment.. Instead on passing $1 and $2, I can read parameter file using

. /parameter_path/dsquestnet.param
That would suppose that your parameter file is correctly formatted (the '$' at the beginning of the lines should be removed)

What is your script supposed to achieve exactly ?
This User Gave Thanks to ctsgnb For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need list of input and output parameter of task in a text file, using shell script

//file begin ===== //some code task abcd_; input x; input y,z; //some comment output w; //some comment reg p; integer q; begin //some code end endtask : abcd_ //some code //file end ===== expected output from above... (1 Reply)
Discussion started by: rishifrnds
1 Replies

2. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (3 Replies)
Discussion started by: Debalina Roy
3 Replies

3. Shell Programming and Scripting

How to pass the parameter in xml file in UNIX shell script?

Hi, I have an XML file like the following... <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ONDEMAND_JOB VERSION="5.1" LOCALE="en_US"> <IMPORT_JOBSET TC_CONNECTION_NAME="default" ENVIRONMENT="PRD" USERNAME="Administrator" PASSWORD="AdminPassword" CALENDAR="Main Monthly Calendar"... (2 Replies)
Discussion started by: Debalina Roy
2 Replies

4. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

5. Shell Programming and Scripting

How to read a directory as parameter in shell script?

Hi All, I have written a shell script to compile an oracle R12 form and also a procedure is called from it. The procedure registers the form, function and creates a menu entry. I took directory as a parameter. Code is as below: #!/bin/ksh echo... (3 Replies)
Discussion started by: veena484
3 Replies

6. Shell Programming and Scripting

How to write CLOB parameter in a file or XML using shell script?

I executed a oracle stored procedure using shell script. How can i get the OUT parameter of the procedure(CLOB) and write it in a file or XML in UNIX environment using shell script? (2 Replies)
Discussion started by: vel4ever
2 Replies

7. Shell Programming and Scripting

Read parameter file in a shell script to unload a DB2 Table???

Hi , I Have following requirement: DB2 Sql query to pass from a parameter file for example, I would create a parameter file with (SELECT column 1, column 2 FROM Table name) then job would read it and create a file with the contents named table.txt How to write/modify below ksh script to... (10 Replies)
Discussion started by: developer.dwh9
10 Replies

8. Shell Programming and Scripting

Passing parameter from one file to shell script

Hi All, I have a 2 files. File1 i am generating using an ETL tool, which is a comman seperated delimited file which contains country code & load date. everytime, this country code will be updated from a table. It might be AB or BA & ld_date will be for which date we need to load the file. ... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies

9. Shell Programming and Scripting

Read from file as script parameter

I have a file with userIDs, one per line no spaces. I have a script that accepts userIDs as a parameter and outputs information about them. What I have had to do in the past was to modify each line of the file with userIDs to call the script with the userID and pipe the output to a data file. ... (2 Replies)
Discussion started by: vmaxx
2 Replies

10. Shell Programming and Scripting

parameter file for a shell script

Hi I was able to pass parameters to a shell script from the command line but now, I am trying to make the shell script to get those parameters/values from a file. Please give me ideas how to do this or if you have an example or website that shows how to do this. I tried searches but it... (2 Replies)
Discussion started by: bryan
2 Replies
Login or Register to Ask a Question