我的shell脚本在执行后停止 [英] My shell script stops after exec

查看:483
本文介绍了我的shell脚本在执行后停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个如下所示的shell脚本:

I'm writing a shell script that looks like this:

 for i in $ACTIONS_DIR/*
    do
            if [ -x $i ]; then
                    exec $i nap
            fi
    done

现在,我要实现的目标是列出$ ACTIONS_DIR中的每个文件以执行该文件. $ ACTIONS_DIR下的每个文件都是另一个Shell脚本.

Now, what I'm trying to achieve is to list every file in $ACTIONS_DIR to be able to execute it. Each file under $ACTIONS_DIR is another shell script.

现在,这里的问题是,使用exec之后,脚本会停止并且不会转到下一个文件.任何想法为什么会这样?

Now, the problem here is that after using exec the script stops and doesn't go to the next file in line. Any ideas why might this be?

推荐答案

exec替换了shell进程.如果只想将该命令作为子进程调用,则将其删除.

exec replaces the shell process. Remove it if you only want to call the command as a subprocess instead.

这篇关于我的shell脚本在执行后停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆