2016-11-23 105 views
0

我全部如何从第二个获得返回值。 Shell脚本在1日执行。 Shell执行? (Unix Korn Shell)

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

像这样

1日脚本:

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} 

结果变量是空的第一凭证,任何想法?

回答

0
Result=$(…)

将存储到$Result任何被命令在$(…)印刷(未返回值),从而代替return ${return_value},使用echo ${return_value}