BASH脚本在完成之前退出

时间:2016-04-06 18:36:40

标签: bash expect sigint sigchld

我有一个很长的bash脚本,可以做很多事情来达到这一点......

(在案例陈述的最后)......

    {
    /usr/bin/expect << EOF
    set timeout 120
    spawn ssh -o StrictHostKeyChecking=no root@$AMHOST1$DOMAIN "/opt/cert_hell.sh"\
    expect assword:
    send "$PASSWD\r"
    expect #
    EOF
    }
    ;;
    esac

    case $ADMCFG in
       ($AMHOST2)

    echo "############ Now we move on with our installation... ##############"
    echo ""
    # installation
    mkdir -p /path/to/install/directory
    cd /path/to/install/directory
    unzip /path/to/software/source.zip`

此时它只是在没有输出到stdout的情况下死掉。我跑了一个strace -f,这是相关的结果:

    [pid  3770] +++ exited with 0 +++
    <... wait4 resumed> [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 3770
    rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f4a5d957d40}, {0x4438a0, [], SA_RESTORER, 0x7f4a5d957d40}, 8) = 0
    rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
    --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=3770, si_status=0, si_utime=6, si_stime=8} ---
    wait4(-1, 0x7fff3323ddd8, WNOHANG, NULL) = -1 ECHILD (No child processes)
    rt_sigreturn()                          = 0
    read(255, "exit 0\n\n# Here we begin configur"..., 4316) = 374
    rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
    rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
    exit_group(0)                           = ?
    +++ exited with 0 +++

我不确定此字符串&#39; 是否读取(255,&#34;退出0 ... &#39;是罪魁祸首,我也无法确定原因正在退出。它会继续前进,并在它死亡之前暂时尝试执行解压缩操作。如果有人有任何想法,他们将不胜感激。

1 个答案:

答案 0 :(得分:1)

抱歉,接下来解压缩是什么“`”unzip /path/to/software/source.zip?