pan.sh没有在eval

时间:2015-09-16 12:10:03

标签: bash pentaho kettle

我有一个shell脚本,它正在调用Pentaho的pan.sh来执行一项工作。作业本身失败了,但我似乎无法捕获返回代码以使shell脚本包装器失败。

这是我用来执行批处理的代码:

echo "Processing $FILE file...";
cmd="./pan.sh -file=$FILE -param:db.name=${DB_NAME} -param:db.host=${DB_HOST} -param:db.port=${DB_PORT} -param:db.user=${DB_USER} db.password=${DB_PASSWORD} -param:dataload.dir=${DATALOAD_DIR}"
eval $cmd
ret_code = $?
echo $ret_code
if [ $ret_code -ne 0 ]
  then
    echo "return code = ${ret_code}"
else
  echo "return code is ok ${ret_code}"
fi;

然后输出的日志的相关部分如下所示。您可以看到它没有在ret_code变量中输出任何内容。我无法发现问题所在。它可能是bash,也可能是pan.sh。我不确定。

utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Language Lookup.0 - Finished processing (I=2, O=0, R=3, W=3, U=0, E=0)
20:04:51.448 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Existing Id Lookup.0 - Finished processing (I=4, O=0, R=3, W=3, U=0, E=0)
20:04:51.450 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Add constants.0 - Finished processing (I=0, O=0, R=3, W=3, U=0, E=0)
20:04:51.453 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Filter rows.0 - Finished processing (I=0, O=0, R=3, W=3, U=0, E=0)
20:04:51.469 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Allocate New Key.0 - Finished processing (I=0, O=0, R=2, W=0, U=0, E=2)
20:04:51.470 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Abort.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=1)
20:04:51.470 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - customers - Transformation detected one or more steps with errors.
20:04:51.471 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - customers - Transformation is killing the other steps!
20:04:51.471 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Replace CSV Nulls.0 - Finished processing (I=0, O=0, R=1, W=1, U=0, E=0)
20:04:51.472 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Sort by Email.0 - Finished processing (I=0, O=0, R=1, W=0, U=0, E=0)
20:04:51.830 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Pan - Finished!
20:04:51.831 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Pan - Start=2015/09/16 20:04:35.089, Stop=2015/09/16 20:04:51.830
20:04:51.832 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 2015/09/16 20:04:51 - Pan - Processing ended after 16 seconds.
20:04:51.848 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - 
20:04:51.849 DEBUG com.ocscommerce.services.utils.dataload.DataLoadProcessWrapper 76 run - return code is ok 

1 个答案:

答案 0 :(得分:2)

首先,你不能在赋值语句中将等号放在等号周围。 (这样做会使它成为常规命令调用,而不是赋值。)

for

其次,请勿在此使用Start.test = 1 + tmp Ende.test = 13 + tmp 。定义一个函数:

ret_code=$?

或将命令与参数分开:

eval