0

我编写了这段代码,可以在我的 Linux 远程机器上执行一些不同输入的重复实验。

#!/bin/bash
#timeout 10m
trap "exit 1" INT 

repeat() {
  executiontime=$( /usr/bin/time  /home/me/optimathsat-1.5.1-macos-64-bit/bin/optimathsat < file.smt2 2>&1 >/dev/null)
  echo "$executiontime">>results.csv

}
export -f repeat

for length in 30 ; do
    step=0.05
    short=0 #0
    long=1
    for i in {1..10}; do
    ratio=0
        for j in {1..10}; do
                declare -a listofresults
                echo "$length $short $long $ratio">>results.csv
                python3 main.py "$length" "$short" "$long" "$ratio">file.smt2
                chmod 775 file.smt2
                declare total=0
                declare m=0
                parallel -n0 repeat ::: {1..10}
                ratio=$(echo "scale=10; ($ratio) + ($step)" | bc) 
            done
            short=$(echo "scale=10; ($short) + ($step)" | bc)
            long=$(echo "scale=10; ($long) - ($step)" | bc)
        done
    done
trap - INT

我已经在我自己的 mac 机器上执行了这段代码并且它有效(使用 gtime 而不是 /usr/bin/time )但现在我收到了这个错误,我不知道它是什么意思/

   0inputs+0outputs (0major+66minor)pagefaults 0swaps
    /home/me/optimathsat-1.5.1-macos-64-bit/bin/optimathsat: 1: /home/project/optimathsat-1.5.1-macos-64-bit/bin/optimathsat:

 Syntax error: word unexpected (expecting ")")

当我尝试手动执行指令时,我得到了这个:

src$ python3 main.py 10 0.5 0.5 0.5>file.smt2

我检查了file.smt2,它应该是,然后发生这种情况

src$ /home/project/optimathsat-1.5.1-macos-64-bit/bin/optimathsat < file.smt2
    -bash: /home/project/optimathsat-1.5.1-macos-64-bit/bin/optimathsat: cannot execute binary file: Exec format error
4

1 回答 1

0
  • 您可以从带有跟踪的调试开始,$ bash -x myscript.sh. 它将显示导致错误的行。请参阅Linux 文档项目的指南
  • 我总是觉得 macOS 不区分大小写,尽管它保留了大小写。也就是说,我可以echo "Hello" > foo; cat Foo在 macOS 上,但不能在 Linux 上。
  • macOS 基于 BSD,而不是基于 Linux。有一些基本命令在两个系统之间具有不同的标志。

希望这可以帮助!

于 2019-11-16T17:26:54.587 回答