Aman
Aman

Reputation: 3261

Shell script file takes partial path from parameter file

I have a parameter file(parameter.txt) which contain like below:

SASH=/home/ec2-user/installers
installer=/home/hadoop/path1

And My shell script(temp_pull.sh) is like below:

EPATH=`cat $1|grep 'SASH' -w| cut -d'='  -f2`
echo $EPATH
${EPATH}/data-integration/kitchen.sh   -file="$KJBPATH/hadoop/temp/maxtem/temp_pull.kjb"

When I run my temp_pull.sh like below:

./temp_pull.sh parameter.txt

$EPATH gives me correct path, but 3rd line of code takes only partial path.

Error code pasted below:

/home/ec2-user/installers-->out put of 2nd line  
/data-integration/kitchen.sh: No such file or directory**2-user/installer** -->out put of 3rd line

Upvotes: 0

Views: 111

Answers (2)

Aman
Aman

Reputation: 3261

The problem is file which we were using was copied from windows to UNIX.So delimiter issue are the root cause.

By using dos2unix paramfile.txt we are able to fix the isue.

command:

dos2unix paramfile.txt

This will convert all the delemeter of windows to unix format.

Upvotes: 0

fedorqui
fedorqui

Reputation: 290105

There is no need to manually parse the values of the file, because it already contains data in the format variables are defined: var=value.

Hence, if the file is safe enough, you can source the file so that SASH value will be available just by saying $SASH.

Then, you can use the following:

source "$1"  # source the file given as first parameter
"$SASH"/data-integration/kitchen.sh -file="$KJBPATH/hadoop/temp/maxtem/temp_pull.kjb"

Upvotes: 1

Related Questions