【问题标题】:calling execu in a bash while loop, not working在bash while循环中调用execu,不起作用
【发布时间】:2014-05-20 10:51:27
【问题描述】:

我有一个 bash 脚本,它必须运行相同的文件(c 执行),但输入参数不同,并将 c 模拟的输出文件保存在不同的文件夹中。我写了这个,但我不知道为什么它不起作用!

mu=1
num=0
while test $num -le 6;do
    mkdir $num
    cd $num
    while test $mu -le 100; do
            ./infosimul "$num" "$mu" 
            mu=$((mu+3))
        done
    mu=0
    cd ../
    num=$((num+1))
done

输出为:

testBash.sh: 7: testBash.sh: ./infosimul: not found

但如果我只跑

./infosimul: 1 3

正常工作。

我是 UBUNTU 用户!

【问题讨论】:

  • 你通过cd $num更改目录所以infosimul不在当前目录中。

标签: bash loops while-loop


【解决方案1】:

您的脚本正在通过调用cd $num 更改目录,而新目录中不存在infosimul 程序。

尝试调用../infosimul 或指定infosimul 的完整路径。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-17
    • 2011-10-19
    • 1970-01-01
    • 1970-01-01
    • 2015-08-02
    • 2017-11-13
    • 1970-01-01
    相关资源
    最近更新 更多