csh脚本自行退出

时间:2013-07-10 14:09:34

标签: linux shell scripting csh

我有一个名为 new_script 的csh脚本(我必须使用csh,我不能使用bash),它会调用另一个名为 soak_script 的脚本12次。 soak_script 会睡12个小时,然后进行一些测试。

我的问题是我的原始脚本( new_script )在 soak_script 执行一次后自动终止。如果我将睡眠时间从12小时减少到30秒,整个脚本工作正常, soak_script 执行12次。为什么会这样?请帮我。我是linux和脚本的初学者,我真的迷路了。

#!/bin/csh -f
clear

echo "*****************************SIMULATION STARTED***********************************"
echo ""
echo "Sim Start Time : `date`"
echo "Sim Folder     : ${cwd}"
echo ""
ls | grep -E 'soak|scan' > ls_all
echo "List of all simulation sub-folders:"
cat ls_all
echo ""

foreach line ( "`cat ls_all`" )
    if ($line =~ *scan*) then
        cd .. 
        echo "CURRENT DIRECTORY: ${PWD}"
        echo "Copying char_nosleep.c to char.c"
        cp char_nosleep.c char.c
        if ($? != 0) then 
            echo "Copying failed"; exit 2
        endif
        cd /u/rahul7/p4/prod/virgo2/diags/src
        echo "CURRENT DIRECTORY: ${PWD}"
        echo "Making char_nosleep.c for $line"
        make
        if ($? != 0) then 
            echo "Making failed"; exit 3
        endif
        wait
        echo "****************************************************************************************************************************************************************************"
        cd bin/vdma/TestSet2_100_100
        cd $line
        echo "CURRENT DIRECTORY: ${PWD}"
        echo "RUNING.."
        echo "Run Start Time : `date`"
        ls | grep ^data > ls_run
        foreach command ( "`cat ls_run`" )
            if ($command =~ *Micron*) then
                ./$command > mcrn_run_out &
            else if ($command =~ *Samsung*) then
                ./$command > ssung_run_out &
            else if ($command =~ *Toshiba*) then
                ./$command > tshba_run_out &
            else
                echo "Micron, Toshiba or Samsung run file not found in $(pwd)!"; exit 4;
            endif
        end
        wait
        rm -f ls_run
        echo "Run End Time : `date`"
        echo "****************************************************************************************************************************************************************************"
        cd ..

else if ($line =~ *soak*) then
    cd .. 
    echo "CURRENT DIRECTORY: ${PWD}"
    echo "Copying char_sleep_12hr.c to char.c"
    cp char_sleep_12hr.c char.c
    if ($? != 0) then 
        echo "Copying failed"; exit 2 
    endif
    cd /u/rahul7/p4/prod/virgo2/diags/src
    echo "CURRENT DIRECTORY: ${PWD}"
    echo "Making char_sleep_12hr.c for $line"
    make
    if ($? != 0) then 
        echo "Making failed"; exit 3
    endif
    wait
    echo "****************************************************************************************************************************************************************************"
    cd bin/vdma/TestSet2_100_100
    cd $line
    echo "CURRENT DIRECTORY: ${PWD}"
    echo "RUNING.."
    echo "Run Start Time : `date`"
    ls | grep ^data > ls_run
    foreach command ( "`cat ls_run`" )
        if ($command =~ *Micron*) then
            ./$command > mcrn_run_out &
        else if ($command =~ *Samsung*) then
            ./$command > ssung_run_out &
        else if ($command =~ *Toshiba*) then
            ./$command > tshba_run_out &
        else
            echo "Micron, Toshiba or Samsung run file not found in $(pwd)!"; exit 4;
        endif
    end
    wait
    rm -f ls_run
    echo "Run End Time : `date`"

    echo "****************************************************************************************************************************************************************************"
    cd ..
endif
end

rm -f ls_all
echo "Sim End Time : `date`"

0 个答案:

没有答案