在另一个退出外部脚本中执行脚本

时间:2011-06-24 12:42:41

标签: bash command-line

我尝试在bash脚本中启动另一个应用程序,但应用程序似乎退出了我的脚本,因此行exec $HOME/bin/sync-iosbeta;没有被执行。我试图将它放在if之外。

if $HOME/bin/BetaBuilder.app/Contents/MacOS/BetaBuilder --args -i "${zip}" -o "${odir}" -u "${ourl}" -r "$PROJECT_FOLDER/README.txt" ; then
    echo "Wil sync"
    exec $HOME/bin/sync-iosbeta;
fi

echo "This text does not get printed either..";

我还尝试使用open启动应用,但即使设置了--args,我也会遇到传递参数的问题。

我在Mac OS上运行。

2 个答案:

答案 0 :(得分:2)

来自 exec 手册:

  

如果指定了command,它将替换shell。没有创建新流程。

只需删除exec和“;”:

if $HOME/bin/BetaBuilder.app/Contents/MacOS/BetaBuilder --args -i "${zip}" -o "${odir}" -u "${ourl}" -r "$PROJECT_FOLDER/README.txt" ; then
    echo "Wil sync"
    $HOME/bin/sync-iosbeta
fi

echo "This text does not get printed either..";

如果 sync-iosbeta 未执行,则可能是它没有正确的权限。尝试:

if $HOME/bin/BetaBuilder.app/Contents/MacOS/BetaBuilder --args -i "${zip}" -o "${odir}" -u "${ourl}" -r "$PROJECT_FOLDER/README.txt" ; then
    echo "Wil sync"
    /bin/sh $HOME/bin/sync-iosbeta
fi

echo "This text does not get printed either..";

答案 1 :(得分:1)

这是执行官的全部观点。 man bash:如果指定了command,它将替换shell。

只需删除exec

相关问题