【问题标题】:How to get a return value from 2nd. Shell script execution in the 1st. Shell executed? (Unix Korn Shell)如何从 2nd 获取返回值。 1号shell脚本执行。壳牌执行? (Unix Korn Shell)
【发布时间】:2017-04-08 03:25:31
【问题描述】:

我都

我想知道如何从 2nd 获取返回值。 shell 执行并将其保存在第一个脚本中的变量中。

类似的东西

第一个脚本:

Result=$(. /dir/to/mysecond/shell/second_shell.sh "Blue")
echo ${Result}

第二个脚本:

if [ $1 == "Blue" ]; then
   return_value="The color is blue"
else
   return_value="The color is not blue"
fi

return ${return_value}

结果变量在第一个脚本中是空的,知道吗?

【问题讨论】:

    标签: shell unix return return-value


    【解决方案1】:

    Result=$(…) 将存储在$(…) 中的命令打印的任何内容(不是返回值)到$Result,因此请使用return ${return_value} 而不是return ${return_value}

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-15
      • 2013-12-17
      • 2016-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多