【问题标题】:set ksh return code from java class从java类设置ksh返回码
【发布时间】:2014-10-27 18:04:38
【问题描述】:

我正在从 ksh 脚本调用 java 类。在 java 类中,它会进行一些错误检查,如果发现错误,则会向用户发送一封电子邮件。发送电子邮件后,我想向脚本返回一个错误代码,例如 11,并据此使其失败。

目前,我的脚本在发送电子邮件时是成功的,但我想让它失败。

这是我的一些 ksh 脚本:

$JAVA_HOME/bin/java alfaSpecificEditCheck.ValDateCheck $edit_env $FILENAME $USERID
  RC=$?
  echo "RC=$RC"
  if [[ $RC -eq 11 ]]; then
    echo "    ALFA Date has failed the edit. Safe exit."
    echo ${FILEPATH} >> ${BASEDIR}/logs/failed_edit
    echo "    ALFA Date check Failed"
  elif [[ $RC -ne 0 ]]; then
    echo "ALFA Date DONE with status $RC ..."
    echo ${FILEPATH} >> ${BASEDIR}/logs/status_fail
    echo "    ALFA Date Failed"
  else
    echo "    ALFA Date Successful" 
  fi
;;

【问题讨论】:

  • 您的 java 文件的代码在哪里?您可以使用 System.exit(11) 来返回错误代码。

标签: java ksh


【解决方案1】:

此评论是正确答案。

Where is the code for your java file? You could use System.exit(11) from where you want to return the error code. –  nikhil Oct 27 at 18:17

【讨论】:

    猜你喜欢
    • 2015-06-16
    • 2011-10-10
    • 1970-01-01
    • 2012-05-16
    • 1970-01-01
    • 2012-10-18
    • 2019-10-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多