我有一个参数文件(parameter.txt),它包含如下所示:
SASH=/home/ec2-user/installers
installer=/home/hadoop/path1我的shell脚本(temp_pull.sh)如下所示:
EPATH=`cat $1|grep 'SASH' -w| cut -d'=' -f2`
echo $EPATH
${EPATH}/data-integration/kitchen.sh -file="$KJBPATH/hadoop/temp/maxtem/temp_pull.kjb"当我像下面这样运行我的temp_pull.sh时:
./temp_pull.sh parameter.txt$EPATH给出了正确的路径,但是第3行代码只需要部分路径。
粘贴在下面的错误代码:
/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发布于 2014-11-04 12:37:52
不需要手动解析文件的值,因为它已经包含了格式变量定义的数据:var=value。
因此,如果文件足够安全,您可以使用source文件,这样SASH值就可以使用,只需说$SASH即可。
然后,您可以使用以下内容:
source "$1" # source the file given as first parameter
"$SASH"/data-integration/kitchen.sh -file="$KJBPATH/hadoop/temp/maxtem/temp_pull.kjb"发布于 2014-11-05 15:42:27
问题是,我们使用的文件是从windows复制到UNIX.So分隔符的问题,这是根本原因。
通过使用dos2unix paramfile.txt,我们能够修复isue。
命令:
dos2unix paramfile.txt这将将窗口的所有延迟表转换为unix格式。
https://stackoverflow.com/questions/26734948
复制相似问题