Hi All,
I need urgent Help from all of you here.
Below is my 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-
./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?
ctsgnb
October 16, 2013, 3:25am
2
Could you show us the contend of parameter_file ?
$ cat dsquestnet.param
$prmDirInput=/dstage/questnet/qnetdv/input
$prmDirScripts=/dstage/questnet/qnetdv/scripts
$prmDirOutput=/dstage/questnet/qnetdv/output
$prmDirStage=/dstage/questnet/qnetdv/stage
ctsgnb
October 16, 2013, 3:49am
4
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)
. ./yourfile.env
in csh :
source ./yourfile.env
so instead of
export `parameter_file.param`
use
. ./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 ...
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
ctsgnb
October 16, 2013, 4:40am
6
A short example is often better than a long story :
$ 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 ----------
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 ?
1 Like