首页 > 解决方案 > 修改shell脚本以在windows中执行

问题描述

我需要使这个脚本适应我的环境:

for entry in `ls *.tcl`
do
    if [ -f "$entry" ];then
        echo "$entry" 
        echo test.bat -w test_workspace -file ./$entry
        test.bat -w test_workspace -file ./$entry
    fi;     
done

我把这个脚本和 test.bat 放在同一个地方,但我有这个错误:

test.bat -w test_workspace -file ./script1.tcl
bash: test.bat: command not found

标签: windowsbashshell

解决方案


你可以调用cmd命令来执行 bat 文件,如下所示:

for entry in `ls *.tcl`
do
    if [ -f "$entry" ];then
        echo "$entry" 
        echo test.bat -w test_workspace -file ./$entry
        cmd /c test.bat -w test_workspace -file ./$entry
    fi;     
done

推荐阅读